#include <bits/stdc++.h>
using namespace std;
void _a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z() {
  long long n, k, q = -1, c = 0;
  string s, t;
  cin >> s >> t;
  long long x = abs((long long)s.size() - (long long)t.size());
  c += x;
  if (t == s) return void(cout << 0);
  if ((long long)s.size() < (long long)t.size()) swap(s, t);
  for (int i = x; i < max((long long)s.size(), (long long)t.size()); i++) {
    if (s[i] != t[i - x]) q = i;
  }
  if (q == -1)
    cout << x;
  else
    cout << x + (q + 1 - x) * 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    _a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z();
  }
  return 0;
}
