VK Cup 2015 - Round 2 (unofficial online mirror, Div. 1 only)
E
Correcting Mistakes
Codeforces
1800
原题
← DF →
翻译中…

Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.

翻译中…

Polycarp needed to write a code that could, given two words, check whether they could have been obtained from the same word as a result of typos. Polycarpus suggested that the most common typo is skipping exactly one letter as you type a word.

翻译中…

Implement a program that can, given two distinct words $*S*$ and $*T*$ of the same length $*n*$ determine how many words $*W*$ of length $*n* + 1$ are there with such property that you can transform $*W*$ into both $*S*$, and $*T*$ by deleting exactly one character. Words $*S*$ and $*T*$ consist of lowercase English letters. Word $*W*$ also should consist of lowercase English letters.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 100 000$) — the length of words $*S*$ and $*T*$.

翻译中…

The second line contains word $*S*$.

翻译中…

The third line contains word $*T*$.

翻译中…

Words $*S*$ and $*T*$ consist of lowercase English letters. It is guaranteed that $*S*$ and $*T*$ are distinct words.

翻译中…

Output

翻译中…

Print a single integer — the number of distinct words $*W*$ that can be transformed to $*S*$ and $*T*$ due to a typo.

翻译中…

Note

翻译中…

In the first sample test the two given words could be obtained only from word "treading" (the deleted letters are marked in bold).

翻译中…

In the second sample test the two given words couldn't be obtained from the same word by removing one letter.

翻译中…

In the third sample test the two given words could be obtained from either word "tory" or word "troy".

翻译中…

样例

Input #1
7
reading
trading
Output #1
1
InputCopy OutputCopy
Input #2
5
sweet
sheep
Output #2
0
InputCopy OutputCopy
Input #3
3
toy
try
Output #3
2
InputCopy OutputCopy
题目信息
题号
533E
时间限制
2 s
内存限制
256 MB
标签
构造
动态规划
贪心
哈希
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。