#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int pos = 1;
  int i = 0, j = 0;
  while (i < s.size() and j < t.size()) {
    if (s[i] == t[j]) {
      i++;
      j++;
    } else
      j++;
  }
  cout << i + 1 << endl;
  return 0;
}
