x,n = map(int,input().split()) d = x + n if d <= 7: print(d) elif d % 7 == 0: print(7) else: print(d % 7)