#include <bits/stdc++.h>
using namespace std;
const long long MOD_CONST = 1000000007;
const long long BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;
int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[cnt]) {
      cnt = 0;
    }
    if (s[i] == t[cnt]) {
      cnt++;
    }
  }
  cout << (2 * n - cnt) << endl;
}
