#include <bits/stdc++.h>
using namespace std;
int ans, l1, l2;
string s1, s2;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> s1 >> s2;
  if (s2.size() > s1.size()) swap(s1, s2);
  l1 = s1.size(), l2 = s2.size();
  for (int i = 1; i <= l2; i++)
    if (s1[l1 - i] != s2[l2 - i])
      return cout << l1 - i + 1 + l2 - i + 1 << endl, 0;
  if (l1 > l2) return cout << l1 - l2 << endl, 0;
  return cout << 0 << endl, 0;
}
