{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cbr\u003eA cop is pursuing a thief in a rectangular \u003ci\u003eH\u003c/i\u003ex\u003ci\u003eW\u003c/i\u003e grid. Both thief and cop occupy one cell of the grid. Initially they are placed in it somehow, and then make moves in turn. At each move one must go from a cell to any of the cells adjacent to it side-by-side. Note that it\u0027s not allowed to stay in the same cell. It\u0027s also not allowed to move outside the grid.\u003cbr\u003eThe cop catches the thief if they\u0027re in the same cell. The aim of the cop is to catch the thief as fast as possible, the aim of the thief is not to be caught, or at least to be free for as many moves as possible. They both see each other and the walls of the grid, so they always know the coordinates of themselves and of each other.\u003cbr\u003eIf both players play optimally, will the cop catch the thief, and if he will, after which move it will happen? (moves are numbered starting from 1, for example, if the cop moves first, then move 1 is the cop\u0027s move, move 2 is the thief\u0027s move, move 3 is the cop\u0027s move, etc)\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/div\u003eThe first line of input contains two integers \u003ci\u003eH\u003c/i\u003e and \u003ci\u003eW\u003c/i\u003e, 1 ≤ \u003ci\u003eH\u003c/i\u003e, \u003ci\u003eW\u003c/i\u003e ≤ 5·10\u003csup\u003e8\u003c/sup\u003e, denoting the number of rows and columns in the grid, respectively. The rows are numbered 1 through \u003ci\u003eH\u003c/i\u003e, the columns are numbered 1 through \u003ci\u003eW\u003c/i\u003e.\u003cbr\u003eThe second line of input contains two integers \u003ci\u003eR\u003c/i\u003e\u003csub\u003e\u003ci\u003ec\u003c/i\u003e\u003c/sub\u003e and \u003ci\u003eC\u003c/i\u003e\u003csub\u003e\u003ci\u003ec\u003c/i\u003e\u003c/sub\u003e, 1 ≤ \u003ci\u003eR\u003c/i\u003e\u003csub\u003e\u003ci\u003ec\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003eH\u003c/i\u003e, 1 ≤ \u003ci\u003eC\u003c/i\u003e\u003csub\u003e\u003ci\u003ec\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003eW\u003c/i\u003e, denoting the row and column of the cell where the cop resides initially.\u003cbr\u003eThe third line of input contains two integers \u003ci\u003eR\u003c/i\u003e\u003csub\u003e\u003ci\u003et\u003c/i\u003e\u003c/sub\u003e and \u003ci\u003eC\u003c/i\u003e\u003csub\u003e\u003ci\u003et\u003c/i\u003e\u003c/sub\u003e, 1 ≤ \u003ci\u003eR\u003c/i\u003e\u003csub\u003e\u003ci\u003et\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003eH\u003c/i\u003e, 1 ≤ \u003ci\u003eC\u003c/i\u003e\u003csub\u003e\u003ci\u003et\u003c/i\u003e\u003c/sub\u003e ≤ \u003ci\u003eW\u003c/i\u003e, denoting the row and column of the cell where the thief resides initially.\u003cbr\u003eInitial positions of the cop and the thief differ.\u003cbr\u003eThe fourth line of input contains either the letter \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eC\u003c/pre\u003e\u0027 (capital English letter C)\u0026nbsp;— if the cop moves first, or the letter \u0027\u003cpre style\u003d\"display: inline;font-size: 120.0%;\"\u003eT\u003c/pre\u003e\u0027 (capital English letter T)\u0026nbsp;— if the thief moves first (without quotes).\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/div\u003eIf the cop can catch the thief with both of them playing optimally, output the number of the move after which it will happen. Otherwise, output 0 (zero).\u003cbr\u003e"}},{"title":"Sample 1","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\u003e2 2\n1 2\n2 1\nC\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 2","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\u003e2 2\n1 2\n2 1\nT\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}