{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003eMasha has recently bought a cleaner robot, it can clean a floor without anybody\u0027s assistance. \u003c/p\u003e\n\u003cp\u003eSchematically Masha\u0027s room is a rectangle, consisting of \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e × \u003ci\u003eh\u003c/i\u003e\u003c/span\u003e square cells of size \u003cspan class\u003d\"tex-span\"\u003e1 × 1\u003c/span\u003e. Each cell of the room is either empty (represented by character \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e.\u003c/span\u003e\u0027), or occupied by furniture (represented by character \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e*\u003c/span\u003e\u0027).\u003c/p\u003e\n\u003cp\u003eA cleaner robot fully occupies one free cell. Also the robot has a current direction (one of four options), we will say that it looks in this direction. \u003c/p\u003e\n\u003cp\u003eThe algorithm for the robot to move and clean the floor in the room is as follows:\u003c/p\u003e\n\u003col\u003e \n \u003cli\u003e clean the current cell which a cleaner robot is in; \u003c/li\u003e\n \u003cli\u003e if the side-adjacent cell in the direction where the robot is looking exists and is empty, move to it and go to step 1; \u003c/li\u003e\n \u003cli\u003e otherwise turn 90 degrees clockwise (to the right relative to its current direction) and move to step 2. \u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eThe cleaner robot will follow this algorithm until Masha switches it off.\u003c/p\u003e\n\u003cp\u003eYou know the position of furniture in Masha\u0027s room, the initial position and the direction of the cleaner robot. Can you calculate the total area of the room that the robot will clean if it works infinitely? \u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains two integers, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eh\u003c/i\u003e\u003c/span\u003e \u003cspan class\u003d\"tex-span\"\u003e(1 ≤ \u003ci\u003ew\u003c/i\u003e, \u003ci\u003eh\u003c/i\u003e ≤ 10)\u003c/span\u003e\u0026nbsp;— the sizes of Masha\u0027s room.\u003c/p\u003e\n\u003cp\u003eNext \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003c/span\u003e lines contain \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eh\u003c/i\u003e\u003c/span\u003e characters each\u0026nbsp;— the description of the room. If a cell of a room is empty, then the corresponding character equals \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e.\u003c/span\u003e\u0027. If a cell of a room is occupied by furniture, then the corresponding character equals \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003e*\u003c/span\u003e\u0027. If a cell has the robot, then it is empty, and the corresponding character in the input equals \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eU\u003c/span\u003e\u0027, \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eR\u003c/span\u003e\u0027, \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eD\u003c/span\u003e\u0027 or \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eL\u003c/span\u003e\u0027, where the letter represents the direction of the cleaner robot. Letter \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eU\u003c/span\u003e\u0027 shows that the robot is looking up according to the scheme of the room, letter \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eR\u003c/span\u003e\u0027 means it is looking to the right, letter \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eD\u003c/span\u003e\u0027 means it is looking down and letter \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eL\u003c/span\u003e\u0027 means it is looking to the left.\u003c/p\u003e\n\u003cp\u003eIt is guaranteed that in the given \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ew\u003c/i\u003e\u003c/span\u003e lines letter \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eU\u003c/span\u003e\u0027, \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eR\u003c/span\u003e\u0027, \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eD\u003c/span\u003e\u0027 or \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eL\u003c/span\u003e\u0027 occurs exactly once. The cell where the robot initially stands is empty (doesn\u0027t have any furniture).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIn the first line of the output print a single integer\u0026nbsp;— the total area of the room that the robot will clean if it works infinitely.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e2 3\u003cbr\u003eU..\u003cbr\u003e.*.\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e4\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4 4\u003cbr\u003eR...\u003cbr\u003e.**.\u003cbr\u003e.**.\u003cbr\u003e....\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e12\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3 4\u003cbr\u003e***D\u003cbr\u003e..*.\u003cbr\u003e*...\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e6\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first sample the robot first tries to move upwards, it can\u0027t do it, so it turns right. Then it makes two steps to the right, meets a wall and turns downwards. It moves down, unfortunately tries moving left and locks itself moving from cell \u003cspan class\u003d\"tex-span\"\u003e(1, 3)\u003c/span\u003e to cell \u003cspan class\u003d\"tex-span\"\u003e(2, 3)\u003c/span\u003e and back. The cells visited by the robot are marked gray on the picture.\u003c/p\u003e\n\u003ccenter\u003e \n \u003cimg class\u003d\"tex-graphics\" SRC\u003d\"CDN_BASE_URL/573c5b771c4dd4ab87380d92e354f973?v\u003d1544231581\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \n\u003c/center\u003e"}}]}