405837: GYM102133 H Plagiarism

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Plagiarismtime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Modern computer systems are quite advanced in plagiarism detection. Consider some text p pretending to be original and text o, which has been copied from some source. Text p is considered as a plagiarism of order k if it has several disjoint substrings of length at least k, concatenation of which is a text o. The order of substrings concatenation to text o corresponds to their order in text p.

Since plagiarism from a single source is a well known problem, engineers started development of a system determining plagiarism from multiple sources. At the very first stage of the system design many training texts are required. Therefore, during the first stage they need to generate a text, which is a plagiarism of order k of two given original texts a and b.

Input

First line contains positive integer k – order of plagiarism for a text, minimal length of which you are required to find.

Second and third lines contain strings a and b – original texts to generate a plagiarism of order k.

All the strings consist of lower case Latin symbols.

1 ≤ k ≤ 100
1 ≤ |a|, |b| ≤ 100
Output

The minimal length of plagiarism of order k text for original texts a and b should be printed in a single line.

ExamplesInput
2
abaaa
babaa
Output
6
Input
3
abacabadabacaba
bababanana
Output
19

加入题单

上一题 下一题 算法标签: