{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe Russian National Operating System (RNOS) is going to be released soon, and its help system is finished already. A user can open the front page of the help system by pressing the F1 button. If the front page is open, then pressing F1 will close it. This seems to be very simple, but the developers of the help system have applied some innovations…\r\n\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe help information is presented on several pages, and each following page describes the same issues as the preceding page but in more detail and in a smaller type. Each page except for the last one has two buttons: “Open next page” and “Close next page.” Of all the open pages, the user can see only the least detailed one, while all the other pages are inaccessible.\r\n\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eYou want to learn using the help of the RNOS. Start with the simple task of changing the set of open help pages in a minimum number of operations.\r\n\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line contains the number \u003ci\u003en\u003c/i\u003e of help pages in the RNOS (1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 50). In the second line you are given the initial set of open pages in the form of a line consisting of \u003ci\u003en\u003c/i\u003e ones and zeros. The \u003ci\u003ei\u003c/i\u003e-th symbol is 1 if the \u003ci\u003ei\u003c/i\u003e-th page is open and 0 otherwise. In the third line you are given the required set of open pages in the same format.\r\n\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eOutput the minimum number of operations (mouse clicks and keystrokes) necessary for changing the set of open pages.\r\n\u003c/div\u003e\u003c/div\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\u003e3\r\n111\r\n000\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Notes","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe optimal sequence of operations: close the first page by pressing F1, close the third page using the button on the second page, open the first page by pressing F1, close the second page using the button on the first page, and close the first page by pressing F1.\u003c/div\u003e\u003c/div\u003e"}}]}