let () =
	let n = read_int () in
	let s = read_line () in
	let t = read_line () in
	let rec loop s t n =
		if n = 0 then 0
		else if Str.last_chars s n = Str.first_chars t n then n
		else loop s t (n - 1)
	in
	loop s t n
	|> ( - ) (n * 2)
	|> print_int
	|> print_newline
