#include <bits/stdc++.h>
using namespace std;
string str, st;
string s;
long long dp[207][207];
long long f(long long i, long long j) {
  if (i == str.size() || j == st.size()) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  if (str[i] == st[j]) return dp[i][j] = 1 + f(i + 1, j + 1);
  return dp[i][j] = max(f(i + 1, j), f(i, j + 1));
}
long long b() {
  long long lo = 0, hi = s.size(), mid;
  long long ans = 0;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    long long fl = 0;
    for (long long i = 0; ((i + mid - 1) < s.size()); i++) {
      if ((mid + st.size()) <= s.size()) {
        str = "";
        str.append(s, 0, i);
        str.append(s, i + mid, s.size());
        memset(dp, -1, sizeof(dp));
        long long z = f(0, 0);
        if (z == st.size()) {
          fl = 1;
          break;
        }
      }
    }
    if (fl == 1) {
      ans = mid;
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  return ans;
}
int main() {
  cin >> s;
  cin >> st;
  cout << b();
  return 0;
}
