#!/bin/bash

read n
read s
read t

i=1

if [ $s = $t ]; then
  echo ${n}
else
  while true
  do
    cnt_s=$((i+1))
    cnt_t=$((n-i))
    tmp_s=$(echo ${s} | cut -b${cnt_s}-)
    tmp_t=$(echo ${t} | cut -b1-${cnt_t})

    if [ $tmp_s = $tmp_t ]; then
      echo  "$(( $n + $n - $(($(echo ${tmp_s} | wc -c) -1 )) ))"
      exit
    fi

    i=$((i+1))
  done
fi