import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String str1;
        while ((str1=reader.readLine())!=null){
            String str2=reader.readLine();
            System.out.println(getDistance(str1,str2));
        }
    }
    public static int getDistance(String str1,String str2){
        char[] arr1=str1.toCharArray();
        char[] arr2=str2.toCharArray();
        int len1=arr1.length;
        int len2=arr2.length;

        int[][] arr=new int[len1+1][len2+1];

        for (int i = 0; i <=len1 ; i++) {
            arr[i][0]=i;
        }
        for (int j = 0; j <=len2 ; j++) {
            arr[0][j]=j;
        }
        for (int i = 1; i <=len1 ; i++) {
            for (int j = 1; j <=len2 ; j++) {
                arr[i][j]=Math.min(arr[i-1][j],arr[i][j-1])+1;
                if(arr1[i-1]==arr2[j-1]){
                    arr[i][j]=Math.min(arr[i][j],arr[i-1][j-1]);
                }else {
                    arr[i][j]=Math.min(arr[i][j],arr[i-1][j-1]+1);
                }
            }
        }
        return arr[len1][len2];
    }
}