import sys import math from collections import deque,Counter from sys import stdin #sys.setrecursionlimit(10**7) int1=lambda x: int(x)-1 stinput=lambda :stdin.readline()[:-1] ii=lambda :int(stinput()) mi=lambda :map(int, stdin.readline().split()) li=lambda :list(mi()) mi1=lambda :map(int1, stdin.readline().split()) li1=lambda :list(mi1()) mis=lambda :map(str, stdin.readline().split()) lis=lambda :list(mis()) from collections import defaultdict #d=defaultdict(int) #d=defaultdict(lambda:1) mod=10**9+7 Mod=998244353 INF=10**18 ans=0 x,y=mi() def calc(x): x=abs(x) return min(x,12-x) for i in range(12): if calc(i-x)==calc(i-y)==4: print(i)