#include<cstdio>
#include<algorithm>
using namespace std;

char s1[1001], s2[1001];
int n1, n2, dp[1001][1001], INF = 1000000000;

int main() {
  scanf("%s%s", s1, s2);
  while (s1[n1] != 0) n1++;
  while (s2[n2] != 0) n2++;
  for (int i = 0; i <= n1; i++) for (int j = 0; j <= n2; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i <= n1; i++) dp[i][0] = i;
  for (int i = 0; i <= n2; i++) dp[0][i] = i;
  for (int i = 0; i < n1; i++) {
    for (int j = 0; j < n2; j++) {
      dp[i+1][j+1] = min(dp[i][j], min(dp[i][j+1], dp[i+1][j])) + 1;
      if (s1[i] == s2[j]) dp[i+1][j+1] = min(dp[i][j], dp[i+1][j+1]);
    }
  }
  printf("%d\n", dp[n1][n2]);
}

