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