m,d = map(int, input().split()) print(m+d+(m==4 and d==1))