#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
string s, a;
int vis[205];
int main() {
  cin >> s >> a;
  int len = s.length(), ans = 0;
  for (int i = 0; i < len; ++i) {
    for (int j = i; j < len; ++j) {
      vis[j] = 1;
      string buf;
      for (int k = 0; k < len; ++k)
        if (!vis[k]) buf += s[k];
      int ok = 0, t = 0;
      for (int k = 0; k < buf.length(); ++k) {
        if (buf[k] == a[t]) {
          t += 1;
          if (t == a.length()) ok = 1;
        }
      }
      if (ok) ans = max(ans, len - (int)buf.length());
    }
    memset(vis, 0, sizeof(vis));
  }
  cout << ans << endl;
  return 0;
}
