Lamps
Time limit1sMemory limit256 MB
Given two binary strings A and B of length N, find the fewest range set-to-0, set-to-1, or flip operations that turn A into B.
Problem
A long hallway has lamps in a row. The lamps are numbered 1 through from left to right. Each lamp is either off or on.
A special mechanism changes the lamp states. In one operation you can do one of the following three things.
- Choose integers and with , and turn off lamps , , , .
- Choose integers and with , and turn on lamps , , , .
- Choose integers and with , and flip lamps , , , (off becomes on, on becomes off).
The initial lamp states are given as a string of length . The -th character () of is 0 if lamp is off and 1 if it is on. The desired states are given as a string of length , encoded the same way. You want to reach the states in using as few operations as possible.
Given , , and , print the minimum number of operations needed to reach the desired states.
Input
The first line contains . The second line contains . The third line contains .
Output
Print one line containing the minimum number of operations needed to reach the desired lamp states.
Constraints
- .
- and are strings of length .
- The characters of and are
0or1.