m,d=map(int,input().split()) ans=23 if 8<m or (m==8 and d>=22): ans+=1 print(ans)