#include <bits/stdc++.h>
using namespace std;
char s[200001];
char t[200001];
int ls, lt;
int f0[200001], f1[200001];
int check(int x) {
  memset(f0, 0, sizeof(f0));
  memset(f1, -1, sizeof(f1));
  for (int i = 1; i <= ls; i++) {
    int bef0 = f0[i - 1], bef1 = f1[i - 1];
    if (bef0 != lt && s[i - 1] == t[bef0]) {
      f0[i] = bef0 + 1;
    }
    if (bef1 != -1 && bef1 != lt && s[i - 1] == t[bef1]) {
      f1[i] = bef1 + 1;
    }
    if (i - x >= 0) {
      f1[i] = max(f1[i], f0[i - x]);
    }
    f0[i] = max(f0[i], f0[i - 1]);
    f1[i] = max(f1[i], f1[i - 1]);
  }
  if (f1[ls] == lt) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  cin >> s;
  cin >> t;
  ls = strlen(s);
  lt = strlen(t);
  int l = 0, r = ls, mid;
  while (l + 1 < r) {
    mid = (l + r) / 2;
    if (check(mid) == 1) {
      l = mid;
    } else {
      r = mid;
    }
  }
  printf("%d", l);
}
