{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eFarmer John has arranged his \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 5,000) cows in a row and many of them are facing forward, like good cows. Some of them are facing backward, though, and he needs them all to face forward to make his life perfect.\u003c/p\u003e\u003cp\u003eFortunately, FJ recently bought an automatic cow turning machine. Since he purchased the discount model, it must be irrevocably preset to turn \u003ci\u003eK\u003c/i\u003e (1 ≤ \u003ci\u003eK\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e)\u003ci\u003e \u003c/i\u003ecows at once, and it can only turn cows that are all standing next to each other in line. Each time the machine is used, it reverses the facing direction of a contiguous group of \u003ci\u003eK\u003c/i\u003e cows in the line (one cannot use it on fewer than \u003ci\u003eK\u003c/i\u003e cows, e.g., at the either end of the line of cows). Each cow remains in the same \u003ci\u003e*location*\u003c/i\u003e as before, but ends up facing the \u003ci\u003e*opposite direction*\u003c/i\u003e. A cow that starts out facing forward will be turned backward by the machine and vice-versa.\u003c/p\u003e\u003cp\u003eBecause FJ must pick a single, never-changing value of \u003ci\u003eK\u003c/i\u003e, please help him determine the minimum value of \u003ci\u003eK\u003c/i\u003e that minimizes the number of operations required by the machine to make all the cows face forward. Also determine \u003ci\u003eM\u003c/i\u003e, the minimum number of machine operations required to get all the cows facing forward using that value of \u003ci\u003eK\u003c/i\u003e.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"Line 1: A single integer: \u003ci\u003eN\u003c/i\u003e\r\u003cbr\u003eLines 2..\u003ci\u003eN\u003c/i\u003e+1: Line \u003ci\u003ei\u003c/i\u003e+1 contains a single character, \u003ci\u003eF\u003c/i\u003e or \u003ci\u003eB\u003c/i\u003e, indicating whether cow \u003ci\u003ei\u003c/i\u003e is facing forward or backward."}},{"title":"Output","value":{"format":"HTML","content":"Line 1: Two space-separated integers: \u003ci\u003eK\u003c/i\u003e and \u003ci\u003eM\u003c/i\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\u003e7\r\nB\r\nB\r\nF\r\nB\r\nF\r\nB\r\nB\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3 3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"For \u003ci\u003eK\u003c/i\u003e \u003d 3, the machine must be operated three times: turn cows (1,2,3), (3,4,5), and finally (5,6,7)"}}]}