{"raw_statement":[{"iden":"problem statement","content":"There is a cleaning robot on the square $(0, 0)$ in an infinite two-dimensional grid.\nThe robot will be given a program represented as a string consisting of four kind of characters `L`, `R`, `U`, `D`.  \nIt will read the characters in the program from left to right and perform the following action for each character read.\n\n1.  Let $(x, y)$ be the square where the robot is currently on.\n2.  Make the following move according to the character read:\n    *   if `L` is read: go to $(x-1, y)$.\n    *   if `R` is read: go to $(x+1, y)$.\n    *   if `U` is read: go to $(x, y-1)$.\n    *   if `D` is read: go to $(x, y+1)$.\n\nYou are given a string $S$ consisting of `L`, `R`, `U`, `D`. The program that will be executed by the robot is the concatenation of $K$ copies of $S$.\nSquares visited by the robot at least once, including the initial position $(0, 0)$, will be cleaned.  \nPrint the number of squares that will be cleaned at the end of the execution of the program."},{"iden":"constraints","content":"*   $S$ is a string of length between $1$ and $2 \\times 10^5$ (inclusive) consisting of `L`, `R`, `U`, `D`.\n*   $1 \\leq K \\leq 10^{12}$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$S$\n$K$"},{"iden":"sample input 1","content":"RDRUL\n2"},{"iden":"sample output 1","content":"7\n\nThe robot will execute the program `RDRULRDRUL`. It will start on $(0, 0)$ and travel as follows:  \n$(0, 0) \\rightarrow (1, 0) \\rightarrow (1, 1) \\rightarrow (2, 1) \\rightarrow (2, 0) \\rightarrow (1, 0) \\rightarrow (2, 0) \\rightarrow (2, 1) \\rightarrow (3, 1) \\rightarrow (3, 0) \\rightarrow (2, 0)$.  \nIn the end, seven squares will get cleaned: $(0, 0), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1)$."},{"iden":"sample input 2","content":"LR\n1000000000000"},{"iden":"sample output 2","content":"2"},{"iden":"sample input 3","content":"UUURRDDDRRRUUUURDLLUURRRDDDDDDLLLLLLU\n31415926535"},{"iden":"sample output 3","content":"219911485785"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}