

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	}

	private static int solve(String s, String t) {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args)throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	}

	private static int solve(String s, String t) {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	}

} Main public static void main(String[] args)throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s=br.readLine(); s br.readLine() br.readLine br String t=br.readLine(); t br.readLine() br.readLine br System.out.println(solve(s,t)) System.out.println System.out System System.out solve(s,t) solve s t String[] args args private static int solve(String s, String t) {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	} solve {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	} int[][] dp=new int[t.length()+1][s.length()+1]; dp new int[t.length()+1][s.length()+1] t.length()+1 t.length() t.length t 1 s.length()+1 s.length() s.length s 1 for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		} int i=1; int i=1; i 1 i<=t.length() i t.length() t.length t i++ i++ i {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		} {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		} for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			} int j=0; int j=0; j 0 j<=s.length() j s.length() s.length s j++ j++ j {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			} {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			} if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				} j==0 j 0 {
					dp[i][j]=dp[i-1][j]+1;
				} dp[i][j]=dp[i-1][j]+1 dp[i][j] dp[i] dp i j dp[i-1][j]+1 dp[i-1][j] dp[i-1] dp i-1 i 1 j 1 {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				} if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					} i>j i j dp[i][j]=Integer.MAX_VALUE dp[i][j] dp[i] dp i j Integer.MAX_VALUE Integer Integer.MAX_VALUE {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					} dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1 dp[i][j] dp[i] dp i j t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1 t.charAt(i-1)==s.charAt(j-1) t.charAt(i-1) t.charAt t i-1 i 1 s.charAt(j-1) s.charAt s j-1 j 1 dp[i-1][j-1] dp[i-1] dp i-1 i 1 j-1 j 1 dp[i-1][j-1]+1 dp[i-1][j-1] dp[i-1] dp i-1 i 1 j-1 j 1 1 int ans=Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		} int val dp[t.length()] dp t.length() t.length t {
			ans=Math.min(ans, val);
		} {
			ans=Math.min(ans, val);
		} ans=Math.min(ans, val) ans Math.min(ans, val) Math.min Math ans val return ans; ans String s s String t t public class Main {

	public static void main(String[] args)throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	}

	private static int solve(String s, String t) {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	}

} public class Main {

	public static void main(String[] args)throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	}

	private static int solve(String s, String t) {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	}

} Main


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s=br.readLine();
		String t=br.readLine();
		
		System.out.println(solve(s,t));

	}

	private static int solve(String s, String t) {
		int[][] dp=new int[t.length()+1][s.length()+1];
		
		for(int i=1;i<=t.length();i++) {
			for(int j=0;j<=s.length();j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]+1;
				}
				else {
					if(i>j) dp[i][j]=Integer.MAX_VALUE;
					else {
						dp[i][j]=t.charAt(i-1)==s.charAt(j-1)?dp[i-1][j-1]:dp[i-1][j-1]+1;
					}
				}
			}
		}
		int ans=Integer.MAX_VALUE;
		for(int val:dp[t.length()]) {
			ans=Math.min(ans, val);
		}
		return ans;
	}

}
