x, y, z = map(int, input().split()) S0, t0 = input().split() t0 = int(t0) S1, t1 = input().split() t1 = int(t1) if S0 == S1: print(abs(t0 - t1)) else: if t0 == t1: print(1) else: print(2)