{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"有N (1 ≤ N ≤ 5,000) 头牛,每头牛要么面朝前方(F)要么面朝后方(B)。现在可以连续驱使连续的K头牛反转。求使得所有的牛面朝前方的最小操作数(M), 和对应的K各是多少?\n"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Line 1: A single integer: \n \u003ci\u003eN\u003c/i\u003e \n \u003cbr\u003eLines 2..\n \u003ci\u003eN\u003c/i\u003e+1: Line \n \u003ci\u003ei\u003c/i\u003e+1 contains a single character, \n \u003ci\u003eF\u003c/i\u003e or \n \u003ci\u003eB\u003c/i\u003e, indicating whether cow \n \u003ci\u003ei\u003c/i\u003e is facing forward or backward.\n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"输出每次反转K头奶牛面向前方所需的最小机器操作次数M。"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e7\nB\nB\nF\nB\nF\nB\nB\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3 3\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n For \n \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)\n \u003c/div\u003e"}}]}