x,t,s;main(z){for(;t=~scanf("%d\n",&z);puts("impossible"+2*!(t-1|!s|x-61)))for(s=t=1;z=getchar()-10;)z-72?x=z,z-77?s--,t&&t++:s&&s++:t--;}