A - Prefix and Suffix 解説 /

実行時間制限: 2 sec / メモリ制限: 256 MB

配点 : 200

問題文

すぬけ君は次の条件を満たす文字列に興味があります。

  • 長さ N 以上である。
  • 先頭 N 文字が文字列 s に一致する。
  • 末尾 N 文字が文字列 t に一致する。

条件を満たす文字列のうち、最も短いものの長さを求めてください。

制約

  • 1≤N≤100
  • s, t は長さ N である。
  • s, t は英小文字のみからなる。

入力

入力は以下の形式で標準入力から与えられる。

N
s
t

出力

条件を満たす文字列のうち、最も短いものの長さを出力せよ。


入力例 1

3
abc
cde

出力例 1

5

最も短い文字列は abcde です。


入力例 2

1
a
z

出力例 2

2

最も短い文字列は az です。


入力例 3

4
expr
expr

出力例 3

4

最も短い文字列は expr です。

Score : 200 points

Problem Statement

Snuke is interested in strings that satisfy the following conditions:

  • The length of the string is at least N.
  • The first N characters equal to the string s.
  • The last N characters equal to the string t.

Find the length of the shortest string that satisfies the conditions.

Constraints

  • 1≤N≤100
  • The lengths of s and t are both N.
  • s and t consist of lowercase English letters.

Input

The input is given from Standard Input in the following format:

N
s
t

Output

Print the length of the shortest string that satisfies the conditions.


Sample Input 1

3
abc
cde

Sample Output 1

5

The shortest string is abcde.


Sample Input 2

1
a
z

Sample Output 2

2

The shortest string is az.


Sample Input 3

4
expr
expr

Sample Output 3

4

The shortest string is expr.