#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 100;
int n, m;
char s[N], t[N];
int pre[N], suf[N];
int got(int len) {
  for (int i = 1; i + len - 1 <= n; i++)
    if (pre[i - 1] + suf[i + len] >= m) return 1;
  return 0;
}
int main() {
  scanf(" %s %s", s + 1, t);
  m = strlen(t);
  n = strlen(s + 1);
  int idx = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (idx >= m)
      pre[i] = idx;
    else {
      if (s[i] == t[idx]) idx++;
      pre[i] = idx;
    }
  }
  idx = 0;
  for (int i = n; i >= 0; i--) {
    if (idx >= m)
      suf[i] = idx;
    else {
      if (s[i] == t[m - idx - 1]) idx++;
      suf[i] = idx;
    }
  }
  int lo = 0, hi = n, ans;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    if (got(mid))
      ans = mid, lo = mid + 1;
    else
      hi = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}
