while True:
try:
m=input().split('.')
ip_1=input().split('.')
ip_2=input().split('.')
error=0
dif=0
num1=''
num2=''
num3=''
for i in range(4):
if int(ip_1[i]) in range(256) and int(ip_2[i]) in range(256) and int(m[i]) in range(256): #初步筛选超出0~255范围的,并转换为二进制
k=bin(int(m[i],10))[2:].zfill(8)
num1+=str(k)
k=bin(int(ip_1[i],10))[2:].zfill(8)
num2+=str(k)
k=bin(int(ip_2[i],10))[2:].zfill(8)
num3+=str(k)
else:
error+=1
break
a= num1.find("0")
b= num1.rfind("1")
if b+1 != a:#找到0开始的地方和1结束的地方,如果位置相差1说明连续
error+=1
if not error:
for j in range(16):
if num1[j]:
if num2[j]==num3[j]:
continue
else:
dif+=1
break
else:
continue
if dif:
print(2)
else:
print(0)
else:
print(1)
except:
break