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