import java.util.*; public class Yukicoder225{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int m = scan.nextInt(); String s = scan.next(); String t = scan.next(); int kazu = 0; for(int i = 0;i < s.length();i++){ if(s.charAt(i) != t.charAt(i) || i == s.length() - 1){ if(i == s.length() - 1 && s.length() < m){ s += t.substring(s.length() , s.length() + 1); if(s.length() == m){ kazu++; break; } }else if(s.charAt(i + 1) == t.charAt(i)){ s = s.substring(0,i) + s.substring(i+1,s.length()); }else{ s = s.substring(0,i) + t.substring(i,i+1) + s.substring(i+1,s.length()); } kazu++; } } System.out.println(kazu); } }