import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s, string t) {
    int n = cast(int) s.length;

    if (s == t) return n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i + j == n) {
                return n + i;
            }

            if (s[i + j] != t[j]) break;
        }
    }

    return n * 2;
}

void main() {
    readint;
    string s = read!string;
    string t = read!string;
    writeln(calc(s, t));
}
