for(;n=readline();)print(n+=[,"st","nd","rd"][/1?.$/.exec(n)]||"th")