#include<cstdio>
#include<iostream> 
#include<cmath>
#include<algorithm>
using namespace std;
int n;
string a,b;
int main()
{
	while(cin >> n)
	{
		cin >> a >> b;
		if(a == b)
			cout << n << endl;
		else
		{
		bool flag = 0;
		int l;
		for(int i = n - 1;i >= 0;i --)
		{
			if(b[i] == a[n - 1])
			{
				int j;
				int tmp = 0;
				for(j = i;j >= 0;j --)
				{
					if(b[j] != a[n - 1 - tmp])
						break;
					tmp++;
				}
				if(j == -1)
				{
					flag = 1;
				}
			}
			if(flag)
			{
				l = i;
			}
		}
		cout << 2 * n - l - 1 << endl;
		}
	}
	return 0;
 } 