{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cbr\u003eA hexagonal leftist tank is a very complicated piece of machinery. It lives on a hexagonal grid, moving from a cell to some of its adjacent cells each turn.\u003cbr\u003eMore specifically, each moment of time the tank is located in some cell (\u003ci\u003ex\u003c/i\u003e,\u003ci\u003ey\u003c/i\u003e) of the grid, heading in one of six directions (see picture for the definition of coordinate system and directions). In one turn, the tank can either move forward in the direction it is heading, or turn left one direction (i.e., increase the direction it is heading by one modulo six), and then move forward in the new direction the tank is heading. Moreover, it is forbidden to move more than \u003ci\u003eb\u003c/i\u003e times in the same direction consecutively.\u003cbr\u003e\u003cimg src\u003d\"CDN_BASE_URL/fa916db7832df121475457e98097a24b?v\u003d1715982640\" style\u003d\"vertical-align: text-bottom;top: -2.0px;max-width: 100.0%;max-height: 100.0%;\"\u003e\u003cbr\u003eYou need to put the tank into cell (\u003ci\u003ex\u003c/i\u003e,\u003ci\u003ey\u003c/i\u003e), heading in direction \u003ci\u003ed\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, given it is located in cell (0,0) initially, heading in direction \u003ci\u003ed\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e. What is the minimal number of turns required to do that?\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/div\u003eThe input file contains five integer numbers \u003ci\u003ex\u003c/i\u003e, \u003ci\u003ey\u003c/i\u003e, \u003ci\u003ed\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, \u003ci\u003ed\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003eb\u003c/i\u003e (-10\u003csup\u003e12\u003c/sup\u003e ≤ \u003ci\u003ex\u003c/i\u003e, \u003ci\u003ey\u003c/i\u003e ≤ 10\u003csup\u003e12\u003c/sup\u003e, 0 ≤ \u003ci\u003ed\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003ed\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e ≤ 5, 2 ≤ \u003ci\u003eb\u003c/i\u003e ≤ 10).\u003cbr\u003e\u003cdiv align\u003d\"left\" style\u003d\"margin-top: 1.0em;\"\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/div\u003eOutput one integer number — the minimal number of turns required to get the tank to the required position.\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\u003e3 3 1 5 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\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\u003e-1 -3 4 2 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e10\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","content":"\u003cbr\u003e\nThe second example is solved as follows (see next page):\n\u003cbr\u003e\u003cimg src\u003d\"CDN_BASE_URL/1a9d8d6889d8620ea6ed40326e913f14?v\u003d1715982640\" style\u003d\"vertical-align: text-bottom;top: -2.0px;max-width: 100.0%;max-height: 100.0%;\"\u003e\n\u003cbr\u003e"}}]}