#include <bits/stdc++.h>
using namespace std;
template <class T>
void ckmin(T &a, T b) {
  a = min(a, b);
}
template <class T>
void ckmax(T &a, T b) {
  a = max(a, b);
}
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);
void solve() {
  string s, t;
  cin >> s >> t;
  int mx = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    for (int j = i; j < (int)s.size(); ++j) {
      int ptr = 0;
      for (int k = i; k <= j; ++k) {
        if (ptr == (int)t.size()) break;
        if (s[k] == t[ptr]) {
          if (ptr == (int)t.size() - 1) {
            ptr++;
            break;
          }
          int lastP = (int)t.size() - 1;
          for (int o = j; o >= k + 1; --o) {
            if (lastP <= ptr) break;
            if (s[o] == t[lastP]) lastP--;
            if (lastP == -1) break;
            if (lastP == ptr) {
              mx = max(mx, o - k - 1);
              break;
            }
          }
          ptr++;
        }
      }
      if (ptr == (int)t.size()) {
        mx = max(mx, max(i, (int)s.size() - j - 1));
      }
    }
  }
  cout << mx;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
