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