#include <bits/stdc++.h>
using namespace std;
class TC {
 public:
  void solve() {
    string s1, s2;
    cin >> s1 >> s2;
    long long i, j, ans;
    bool flag = false;
    for (i = s1.size() - 1, j = s2.size() - 1; i >= 0, j >= 0; i--, j--) {
      if (s1[i] != s2[j]) {
        ans = i + 1 + j + 1;
        flag = true;
        break;
      }
    }
    if (flag)
      cout << ans << "\n";
    else if (i >= 0)
      cout << i + 1 << "\n";
    else if (j >= 0)
      cout << j + 1 << "\n";
    else
      cout << "0"
           << "\n";
  }
};
int32_t main() {
  (ios::sync_with_stdio(false), cin.tie(NULL));
  double start = clock();
  TC tc;
  tc.solve();
  cerr << "[*] Time: " << (clock() - start) * 1.0 / CLOCKS_PER_SEC
       << std::setprecision(3) << " s"
       << "\n";
  return 0;
}
