#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    long long min=0,max=0,total=0;
    
    int x,n;
    cin >>x;
    for (int i=1; i<=x; i++) {
        
        cin >> n;
        
        if(i==1){
            
            
            min =n;
            max=n;
            total=n;
        }else {
            if(n<min){
                min=n;
            }
            if(n>max){
                max=n;
            }
            
            total=total+n;
        }
    }
    cout <<min<<" "<<max<<" "<<total<<endl;
    
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int N; cin >> N;
	string s, t; cin >> s >> t;
	string tmp;
	int ans = INF;
	for (int i = 0; i <= t.length(); i++) {
		tmp = s;
		tmp = s + t.substr(t.length()-i);
		if (tmp.substr(0,N) == s &&
		    tmp.substr(i,N) == t) ans = min(ans, (int)tmp.length());
	}
	cout << ans << endl;
}