import std.stdio, std.string, std.algorithm;

void main() {
     immutable s1 = readln.chomp;
     immutable s2 = readln.chomp;

     int[][] dp = new int[][](s1.length+1, s2.length+1);

     for( int i=0; i<=s1.length; ++i ) dp[i][0] = i;
     for( int i=0; i<=s2.length; ++i ) dp[0][i] = i;

     for( int i=1; i<=s1.length; ++i ) {
          for( int j=1; j<=s2.length; ++j ) {
               immutable cost = s1[i-1] == s2[j-1] ? 0 : 1;
               dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + cost);
          }
     }

     dp[$-1][$-1].writeln;
}