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