Problem:
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.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<cstdio>
#define neko 110
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int n,flag,ans;
char a[neko],b[neko];
int cmin(int a,int b){return a<b?a:b;}
int main()
{
	scanf("%d%s%s",&n,a+1,b+1),ans=n+n;
	f(i,1,n)
	{
		flag=0;
		if(a[i]==b[1]){f(j,i+1,n)if(a[j]^b[j-i+1]){ans=cmin(ans,n+n-(j-i)),flag=1;break;}}
		else flag=1;
		if(!flag)ans=cmin(ans,n+n-(n-i+1));
	}return printf("%d\n",ans),0;
}