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