import java.util.Scanner;

public class Main{
    static int dp[][];
    private static int memo(String a, String b, int i, int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    static int dp[][];
    private static int memo(String a, String b, int i, int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    }
} Main static int dp[][]; dp private static int memo(String a, String b, int i, int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    } memo {
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    } if(dp[i][j]!=-1){
            return dp[i][j];
        } dp[i][j]!=-1 dp[i][j] dp[i] dp i j -1 1 {
            return dp[i][j];
        } return dp[i][j]; dp[i][j] dp[i] dp i j if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        } j==b.length() j b.length() b.length b {
            dp[i][j] = 0;
            return 0;
        } dp[i][j] = 0 dp[i][j] dp[i] dp i j 0 return 0; 0 if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        } i == a.length() i a.length() a.length a {
            dp[i][j] = 2000;
            return 2000;
        } dp[i][j] = 2000 dp[i][j] dp[i] dp i j 2000 return 2000; 2000 if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        } a.charAt(i)==b.charAt(j) a.charAt(i) a.charAt a i b.charAt(j) b.charAt b j {
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        } dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1)) dp[i][j] dp[i] dp i j Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1)) Math.min Math memo(a, b, i+1, 0) memo a b i+1 i 1 0 memo(a, b, i+1, j+1) memo a b i+1 i 1 j+1 j 1 {
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        } dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1)) dp[i][j] dp[i] dp i j Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1)) Math.min Math memo(a, b, i+1, 0) memo a b i+1 i 1 0 1 + memo(a, b, i+1, j+1) 1 memo(a, b, i+1, j+1) memo a b i+1 i 1 j+1 j 1 return dp[i][j]; dp[i][j] dp[i] dp i j String a a String b b int i i int j j public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.nextLine(); a sc.nextLine() sc.nextLine sc String b = sc.nextLine(); b sc.nextLine() sc.nextLine sc dp = new int[a.length()+1][b.length()+1] dp new int[a.length()+1][b.length()+1] a.length()+1 a.length() a.length a 1 b.length()+1 b.length() b.length b 1 for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1; int i=0; int i=0; i 0 i<=a.length() i a.length() a.length a i++ i++ i for(int j=0;j<=b.length();j++)
                dp[i][j] = -1; for(int j=0;j<=b.length();j++)
                dp[i][j] = -1; int j=0; int j=0; j 0 j<=b.length() j b.length() b.length b j++ j++ j dp[i][j] = -1; dp[i][j] = -1 dp[i][j] dp[i] dp i j -1 1 System.out.println(memo(a, b, 0, 0)) System.out.println System.out System System.out memo(a, b, 0, 0) memo a b 0 0 sc.close() sc.close sc String[] args args public class Main{
    static int dp[][];
    private static int memo(String a, String b, int i, int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    }
} public class Main{
    static int dp[][];
    private static int memo(String a, String b, int i, int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main{
    static int dp[][];
    private static int memo(String a, String b, int i, int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        if(j==b.length()){
            dp[i][j] = 0;
            return 0;
        }
        if(i == a.length()){
            dp[i][j] = 2000;
            return 2000;
        }
        if(a.charAt(i)==b.charAt(j)){
            dp[i][j] = Math.min(memo(a, b, i+1, 0), memo(a, b, i+1, j+1));
        }else{
            dp[i][j] = Math.min(memo(a, b, i+1, 0), 1 + memo(a, b, i+1, j+1));
        }
        return dp[i][j];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
        dp = new int[a.length()+1][b.length()+1];
        for(int i=0;i<=a.length();i++)
            for(int j=0;j<=b.length();j++)
                dp[i][j] = -1;
        System.out.println(memo(a, b, 0, 0));
        sc.close();
    }
}