a,b = map(int,input().split())
temp = (a+b)%7
print(temp if temp != 0 else 7)