#include <bits/stdc++.h>
using namespace std;
char s[210], t[210];
int l[210], r[210];
int main() {
  cin >> (s + 1) >> (t + 1);
  int len_s = strlen(s + 1);
  int len_t = strlen(t + 1);
  memset(l, 0, sizeof l);
  memset(r, 0, sizeof r);
  for (int i = 1; i <= len_s; i++) {
    if (s[i] == t[l[i - 1] + 1]) {
      l[i] = l[i - 1] + 1;
    } else {
      l[i] = l[i - 1];
    }
  }
  for (int i = len_s; i >= 1; i--) {
    if (s[i] == t[len_t - r[i + 1]]) {
      r[i] = r[i + 1] + 1;
    } else {
      r[i] = r[i + 1];
    }
  }
  int ans = 0;
  for (int i = 1; i <= len_s; i++) {
    for (int j = len_s; j >= i; j--) {
      if (l[i - 1] + r[j + 1] >= len_t) {
        ans = max(ans, j - i + 1);
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
