Help system
How wonderful it is to live in this world! Even the help system is ready for use, but first, you need to press the F1 key. This will open the help's title page. If this page is already open, pressing the F1 key will close it. It seems simple enough. But even here, there are innovations.
All the help information is spread across several pages. Each subsequent page provides the same content as the previous one, but in more detail and with a smaller font. Each page, except the last one, has two buttons: "open next page" and "close next page". Of all the open pages, the user can only see the least detailed one, while all others are inaccessible.
You want to learn how to use this system. Start with a simple task—try to change the set of open help pages by pressing the buttons the minimum number of times.
Input
The first line contains a single number N—the number of pages in the system (1 ≤ N ≤ 50). The second line describes the initial set of open pages as a string of N characters, each either zero or one. The i-th character is one if the i-th page is open and zero otherwise. The third line, in a similar format, describes the set of open pages that need to be achieved. Characters are considered numbered from left to right starting with 1, which corresponds to the title page.
Output
Output a single line with the answer to the problem: the minimum number of button presses required to achieve the target set of pages (as per the third line of the input file) from the initial set of pages (which corresponds to the second line of the input file).
Explanation. Close the first page with the F1 button (resulting in 011), then from the second page close the third (010). Now press F1 again to open the first page (110), then from the first page close the second (100), and finally, by pressing F1, close the first page to achieve the target set 000.