#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  int counter = 0;
  cin >> s1 >> s2;
  int n = s1.size(), m = s2.size();
  int i = n - 1, j = m - 1;
  while (i >= 0 && j >= 0 && s1[i] == s2[j]) {
    i--;
    j--;
    counter += 2;
  }
  cout << n + m - counter << '\n';
  return 0;
}
