for(;s=readline(c=0);print(i<4?-1:c))for(i in s)/^(.)\1|dn/i('UXLI'[i]+(/..$/(s)+s)[i])||c++
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page