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