#include <bits/stdc++.h>
using namespace std;
int main() {
  char colour[50], instruction[50];
  cin >> colour;
  cin >> instruction;
  int n = 1;
  for (int i = 0, j = 0; j < strlen(instruction); j++) {
    if (colour[i] == instruction[j]) {
      i++;
      n = i + 1;
    } else
      continue;
  }
  cout << n;
}
