M,D=list(map(int,input().split()))
print(M+D+(M==4 and D==1))