#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int l1, l2, i, ans;
  string s, t;
  cin >> s >> t;
  l1 = s.length();
  l2 = t.length();
  int p1, p2;
  p1 = l1 - 1;
  p2 = l2 - 1;
  while (p1 >= 0 && p2 >= 0) {
    if (s[p1] == t[p2]) {
      p1--;
      p2--;
    } else {
      break;
    }
  }
  cout << (p1 + p2 + 2);
  return 0;
}
