
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val N=readLine()!!.toInt()
    val s=readLine()!!.toString()
    val t=readLine()!!.toString()
    val sl=s.length;
    val tl=t.length;
    val l:Int=arrayOf(sl,tl).min()!!
    var suml=sl+tl;
    var common=0;
    for (i in 0..(l-1))
    {
      var andl=0
      for (j in 0..i)
      {
        
        if (s[l-1-i+j]==t[j])
        {
          andl++
        }
        else 
        {
          break
        }
      }
      if (suml-andl<N) break
      common = if (andl>common) andl else common
    }
    println(suml-common)
  }
}
