#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int point = 0;
  for (int i = 0; i < t.length(); i++) {
    if (s[point] == t[i]) point++;
  }
  cout << point + 1 << endl;
  return 0;
}
