import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    }

    public static int solve(String complete, String part) {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    }

    public static int calc(String substr, String part) {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    }

    public static int solve(String complete, String part) {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    }

    public static int calc(String substr, String part) {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    } main {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String complete = sc.nextLine(); complete sc.nextLine() sc.nextLine sc String part = sc.nextLine(); part sc.nextLine() sc.nextLine sc System.out.println(solve(complete, part)) System.out.println System.out System System.out solve(complete, part) solve complete part String[] args args public static int solve(String complete, String part) {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    } solve {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    } if (part.length() > complete.length()) {
            return -1;
        } part.length() > complete.length() part.length() part.length part complete.length() complete.length complete {
            return -1;
        } return -1; -1 1 int count = 0; count 0 for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        } int i = 0; int i = 0; i 0 i < (complete.length() - part.length())+ 1 i (complete.length() - part.length())+ 1 (complete.length() - part.length()) complete.length() complete.length complete part.length() part.length part 1 i++ i++ i {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        } {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        } String substr = complete.substring(i, i + part.length()); substr complete.substring(i, i + part.length()) complete.substring complete i i + part.length() i part.length() part.length part int value = calc(substr, part); value calc(substr, part) calc substr part if(value > count){
                count = value;
            } value > count value count {
                count = value;
            } count = value count value return (part.length() - count); (part.length() - count) part.length() part.length part count String complete complete String part part public static int calc(String substr, String part) {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    } calc {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    } int similar = 0; similar 0 for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        } int i = 0; int i = 0; i 0 i < substr.length() i substr.length() substr.length substr i++ i++ i {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        } {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        } char ch1 = substr.charAt(i); ch1 substr.charAt(i) substr.charAt substr i char ch2 = part.charAt(i); ch2 part.charAt(i) part.charAt part i if(ch1 == ch2) {
                similar++;
            } ch1 == ch2 ch1 ch2 {
                similar++;
            } similar++ similar return similar; similar String substr substr String part part public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    }

    public static int solve(String complete, String part) {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    }

    public static int calc(String substr, String part) {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    }

    public static int solve(String complete, String part) {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    }

    public static int calc(String substr, String part) {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String complete = sc.nextLine();
        String part = sc.nextLine();
        System.out.println(solve(complete, part));
    }

    public static int solve(String complete, String part) {
        if (part.length() > complete.length()) {
            return -1;
        }
        int count = 0;
        for(int i = 0; i < (complete.length() - part.length())+ 1; i++) {
            String substr = complete.substring(i, i + part.length());
            int value = calc(substr, part);
            if(value > count){
                count = value;
            }
        }
        return (part.length() - count);
    }

    public static int calc(String substr, String part) {
        int similar = 0;
        for(int i = 0; i < substr.length(); i++) {
            char ch1 = substr.charAt(i);
            char ch2 = part.charAt(i);
            if(ch1 == ch2) {
                similar++;
            }
        }
        return similar;
    }
}
