#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
bool check(string a, string b) {
  if (a.size() < b.size()) return false;
  int start1 = 0, start2 = 0;
  while (1) {
    if (start2 == b.size()) return true;
    if (start1 == a.size()) return false;
    if (a[start1] == b[start2]) {
      start1++;
      start2++;
    } else
      start1++;
  }
  return false;
}
void solve() {
  string s1, s2;
  cin >> s1 >> s2;
  int ans = 0;
  int len = s1.size();
  for (int i = 0; i < len; i++) {
    for (int j = i; j < len; j++) {
      string cur = "";
      for (int k = 0; k < i; k++) cur += s1[k];
      for (int k = j + 1; k < len; k++) cur += s1[k];
      if (check(cur, s2)) {
        ans = max(ans, (int)(s1.size() - cur.size()));
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
