#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string s, t;
  cin >> s >> t;
  long long n = (long long)s.size();
  long long m = (long long)t.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (j - i + 1 < ans) continue;
      long long j1 = 0;
      for (int k = 0; k < n && j1 < m; k++) {
        if (k == i) {
          k = j;
          continue;
        }
        if (t[j1] == s[k]) j1++;
      }
      if (j1 == m) ans = max(ans, j - i + 1);
    }
  }
  cout << ans << "\n";
  return 0;
}
