#coding: utf-8 sGets=input().split() sTimes=[I,II,III,IIII,V,VI,VII,VIII,IX,X,XI,XII] for i in sTimes: if sGets[0]==i: nStart=sTimes.index(i) nMove_time=sGets[1]%24 nAns=(nStart+nMove_time)%12 print (nAns)