-module('Main').
-export([main/1]).

main(_) -> 
    {ok, [S]} = io:fread("", "~s"),
    {ok, [T]} = io:fread("", "~s"),
    Ans = find_answer(S, T),
    io:format("~p~n", [Ans]),
    halt().

find_answer(S, T) ->
    TLength = string:length(T),
    NumOfSubstring = string:length(S) - TLength,
    lists:min(lists:map(fun(X) ->
                                Sliced = string:slice(S, X, TLength),
                                num_of_difference(Sliced, T)
                        end,
                        lists:seq(0, NumOfSubstring))).

num_of_difference([], []) ->
    0;
num_of_difference([H1|T1], [H2|T2]) ->
    case H1 /= H2 of
        true ->
            1 + num_of_difference(T1, T2);
        false ->
            num_of_difference(T1, T2)
    end.
