#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) {
    string s1, s2;
    cin >> s1 >> s2;
    long long int ans = 0;
    long long int i, j, k;
    i = j = k = 0;
    long long int n = s2.size();
    long long int m = s1.size();
    long long int count = 0;
    map<long long int, long long int> fs, ls;
    while (i < n && j < m) {
      if (s2[i] == s1[j]) {
        fs[i] = j;
        i++;
        j++;
        count = 0;
      } else {
        count++;
        j++;
      }
      ans = max(ans, count);
    }
    ans = max(ans, m - (j));
    i = n - 1;
    j = m - 1;
    while (i >= 0 && j >= 0) {
      if (s2[i] == s1[j]) {
        i--;
        j--;
        ls[i] = j;
        count = 0;
      } else {
        count++;
        j--;
      }
      ans = max(ans, count);
    }
    for (auto x : fs) {
      ans = max(ans, ls[x.first] - x.second);
    }
    ans = max(ans, j + 1);
    cout << ans << "\n";
  }
  return 0;
}
