import java.util.*; import java.math.*; public class Main { static HashMap> all = new HashMap<>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); System.out.println(getCount(sc.next(), sc.next())); } static int getCount(String aSb, String bSb) { HashMap tmp = all.get(aSb); if (tmp != null && tmp.containsKey(bSb)) { return tmp.get(bSb); } int min = Integer.MAX_VALUE; if (aSb.length() == 0 || bSb.length() == 0) { return aSb.length() + bSb.length(); } String aaSb = aSb.substring(1, aSb.length()); String bbSb = bSb.substring(1, bSb.length()); if (aSb.charAt(0) == bSb.charAt(0)) { min = getCount(aaSb, bbSb); } else { min = Math.min(min, getCount(aSb, bbSb) + 1); min = Math.min(min, getCount(aaSb, bSb) + 1); min = Math.min(min, getCount(aaSb, bbSb) + 1); } if (tmp == null) { tmp = new HashMap(); all.put(aSb, tmp); } tmp.put(bSb, min); return min; } }