P9950 [USACO20FEB] Mad Scientist B

Description

Farmer John's distant relative Ben is a mad scientist. This usually causes a lot of friction at family gatherings, but it can sometimes be helpful, especially when Farmer John finds himself facing a unique and unusual problem involving his cows. Farmer John is currently facing a unique and unusual problem involving his cows. He recently ordered $N$ cows ($1 \le N \le 1000$) consisting of two different breeds: Holsteins and Guernseys. In his order, he specified the cows using a string of length $N$, where each character is either `H` (meaning Holstein) or `G` (meaning Guernsey). Unfortunately, when the cows arrived at his farm and he lined them up, the resulting string of breeds was different from what he originally ordered. We call these two strings $A$ and $B$, where $A$ is the breed string Farmer John originally wanted, and $B$ is the breed string of the cows as they arrived. Farmer John did not simply check whether reordering the cows in $B$ could produce $A$; instead, he asked his distant relative Ben to use his scientific talent to solve this problem. After months of research, Ben invented an unusual machine: the Cow Breed Flipper 3000. It can choose any substring of cows and flip their breeds: every `H` in the substring becomes `G`, and every `G` becomes `H`. Farmer John wants to find the minimum number of times this machine must be used to transform his current sequence $B$ into the desired sequence $A$. However, Ben's mad scientist skills do not handle anything other than building strange machines, so you need to help Farmer John solve this computational problem.

Input Format

The first line of input contains $N$. The next two lines contain strings $A$ and $B$. Each string contains $N$ characters, each of which is either `H` or `G`.

Output Format

Output the minimum number of uses of the machine needed to transform $B$ into $A$.

Explanation/Hint

### Sample Explanation 1 First, FJ can flip the substring consisting of only the first character, turning $B$ into `GHGGGHH`. Then, he can flip the substring consisting of the third and fourth characters to obtain $A$. Of course, there are other valid ways to perform two operations. Translated by ChatGPT 5