H,N=map(int,input().split()) print(N.index('H')) if H%10==1: print('st') elif H%10==2: print('nd') elif H%10==3: print('rd') else: print('th')