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