{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eDenis had a \u003ca href\u003d\"http://en.wikipedia.org/wiki/Rubik%27s_Cube\" target\u003d\"_blank\"\u003eRubik\u0027s cube\u003c/a\u003e covered with pretty patterns on his table.\r\nWhen Denis quit the room, Vadik took the cube and made a few rotations.\r\nBut he got scared suddenly:\r\nwhat if Denis get angry about the broken patterns?\r\nVadik wanted to restore the cube to the original state,\r\nbut could not find a way.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eVadik heard somewhere that if one repeats a sequence of rotations again\r\nand again, one would get the original pattern at some point.\r\nGiven this is true, it is possible to revert the cube until Denis returns.\r\nHow many times does Vadik need to apply his sequence of rotations\r\nin order to revert the cube to the original state?\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe description of rotations applied by Vadik in the form of a string\r\nconsisting of letters “U”, “D”, “L”, “R”, “F” and “B”\r\n(upper or lower case).\r\nThey mean rotations of top, bottom, left, right, front and back faces,\r\nrespectively.\r\nLowercase letters mean 90-degree clockwise rotations, uppercase letters mean\r\n90-degree counterclockwise rotations.\r\nThe string is not empty and its length does not exceed 10\u003csup\u003e5\u003c/sup\u003e.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOutput the number of times Vadik needs to apply his sequence of rotations in\r\norder to get the original pattern.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eUd\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr\u003e\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eRRRR\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}