@bpb,

The first number probably is related to groups of regions, obviously will have 16 possible alternatives. Here the best method to discover it is the comparison with country codes of the same region, no formula.