#include <bits/stdc++.h>
using namespace std;
int rd() {
  int sum = 0, flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return flag * sum;
}
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j <= i; j++) {
      int pos = 0;
      for (int p = 0; p < s.size(); p++) {
        if (i >= p && p >= j) {
          continue;
        }
        if (pos == t.size()) {
          break;
        }
        if (t[pos] == s[p]) {
          pos++;
        }
      }
      if (pos == t.size()) {
        ans = max(ans, i - j + 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
