import sys input=sys.stdin.readline import itertools X, Y = map(int, input().split()) l = [X,Y] l.sort() X_prime, Y_prime = l[0], l[1] if abs((X_prime)-(Y_prime)) == 4: digit = [0,1,2,3,4,5,6,7,8,9,10,11] digit_list = digit*2 keys = [0,1,2,3,4,5,6,7,8,9,10,11]*2 d = dict(zip(keys,digit_list)) print(d.get(keys[Y_prime+4])) if abs((X_prime)-(Y_prime)) == 8: print(min(X_prime, Y_prime)+4)