bytelandian-conversions
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

In Byteland,conversion of numbers between different bases has  always been a herculian task.They always make errors in these conversions.
People in Byteland  always write one of the digits wrong when they convert a number to a new base and write it down.  For example, when they convert
the number 56 into binary (base 2), the correct result should be
"110", but they might instead write down "010" or "111".  They never
accidentally delete or add digits, so they might write down a number with
a leading digit of "0" if this is the digit they get wrong.

You are given Bytelandians' output when converting a number N into base 2 and base 3,
Find out the correct original value of N (in base 10). You can
assume that there is a unique solution for N.

Input
There are 2 lines:
Line 1: The base-2 representation of N, with one digit written
        incorrectly.
Line 2: The base-3 representation of N, with one digit written
        incorrectly.

Output
The correct value of N

Constraints
N ≤ 1 billion

SAMPLE INPUT
1010
212

SAMPLE OUTPUT
14


def base3Modifier(base3List,iteration):
	localBase3=list(base3List)
	bitLoc=int(iteration/2)
	bitRemainder=iteration%2
	if(bitRemainder==0):
		if(localBase3[bitLoc]=='2'):
			localBase3[bitLoc]='1'
		elif(localBase3[bitLoc]=='1'):
			localBase3[bitLoc]='0'
		else:
			localBase3[bitLoc]='2'
	else:
		if(localBase3[bitLoc]=='2'):
			localBase3[bitLoc]='0'
		elif(localBase3[bitLoc]=='1'):
			localBase3[bitLoc]='2'
		else:
			localBase3[bitLoc]='1'
	result=int(''.join(localBase3),3)
	return result

ip1=input()
ip2=input()
base2=int(ip1,2)
base2Range=len(ip1)
base3Range=2*len(ip2)
for i in range(base2Range):
	modBase2=base2^int('1',2)<<i
	for j in range(base3Range):
		modBase3=base3Modifier(ip2,j)
		if(modBase2==modBase3):
			print(modBase2)
			break