while""do s=io.read():upper()c=#s function f(a)_,r=s:gsub(a,0)c=c-r end f"^L"f"^.I"f"U.$"f"X$"s=s:sub(3,-3)f"N"print(#s>0 and c or -1)end