#define f(i,e)for(i=e+1;i--;) #define m(p,q)(p<(q)?p=q:p) q[22][22][22][22][102],*t,a,b,c,d,x;char s[110],*p=s;main(S){*****q=1;for(gets(s);*p;p++)f(a,20)f(b,a)f(c,b)f(d,c)*(t=&q[a][b][c][d][p-s])?x=*p-63,*p-82&&x||m(t[2245],*t),*p-75&&x||m(t[1086097],*t),*p-85&&x||m(t[49369],*t),*p-79&&x||m(t[103],*t),*p-73&&x||m(S,m(t[1],d<*t?0:*t+1)),m(t[1],*t):0;x=!printf("%d",S-1);}