#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
template<int n>
struct static_factorial {
  static const int value = static_factorial<n-1>::value*n;

};

template<>
struct static_factorial<0> {
  static const int value = 1;

};

template<char a, char ... as>
struct debug_output {

  template<class T, class ... Ts>
  void operator()(T &t, Ts ... ts) {
    cout << a << "=" << t << "::" << typeid(t).name()<< ", ";
    debug_output<as...>()(ts...);
  }
};

template<char b>
struct debug_output<b> {


  template<class T>
  void operator()(T &t) {
    cout << b << "=" << t << "::" << typeid(t).name()<< endl;
  }
};

template<typename T>
void swap(T&a, T&b) {
  T c=a;
  a=b;
  b=c;
}

template<>
void swap<int>(int&a, int&b) {
  std::cout << "swapping ints!" << std::endl;
  int c=a;
  a=b;
  b=c;
}

int dist(string a, string b) {
  size_t a_len = a.length();
  size_t b_len = b.length();
  vector<vector<int>> m;
  m.resize(a_len+1);
  for (auto i=0;i<a_len+1;i++) {
    //debug_output<'i'>()(i);
    m[i].resize(b_len+1, 0);
  }
  for (auto i=0;i<a_len+1;i++)
    m[i][0] = i;
  for (auto i=0;i<b_len+1;i++)
    m[0][i] = i;
  

  for (auto i=0;i<a_len;i++) {
    for (auto j=0;j<b_len;j++) {
      int cost;
      if (a[i] == b[j])
        cost = 0;
      else
        cost = 1;
      
      m[i+1][j+1] = std::min({m[i][j+1]+1, 
                              m[i+1][j]+1,
                              m[i][j]+cost});

    }
  }
  
  return m[a_len][b_len];
}


int main() {
#ifdef BASIC_TEST
  float a,b;
  int c,d;
  swap(a,b);
  swap(c,d);
#endif

#define TEST3

#ifdef TEST1
  std::cout << static_factorial<10>::value << std::endl;
#endif

#ifdef TEST2
  int a=5;
  int b=3;
  string test="asdasd";

  debug_output<'a', 'b'>()(a, test);
  //debug_output<'a','b','t'>(a,b,test);
  //a=5, b=3, test=asdasd
#endif

#ifdef TEST3
  string a,b;
  std::getline(std::cin, a);
  std::getline(std::cin, b);
  std::cout << dist(a,b) <<std::endl;
#endif

  return 0;
}
