#include <bits/stdc++.h>
using namespace std;
long long n, m = 0, k = 0;
bool test = false, test1 = false;
long long const N = 1e6 + 7;
long long const oo = 1000000007;
vector<long long> v, v1;
vector<pair<long long, long long> > vv;
map<long long, long long> my;
map<long long, long long> my1;
priority_queue<long long> q;
long long t[N];
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
vector<long long> v2[N];
long long z[N];
void dfs(long long s) {
  if (z[s]) return;
  z[s] = 1;
  k++;
  for (long long u = 0; u < v2[s].size(); u++) {
    dfs(v2[s][u]);
  }
}
long long number_divisors(long long n) {
  long long d;
  long long i;
  d = 0;
  for (i = 1; i * i < n; ++i)
    if (n % i == 0) {
      d += 2;
    }
  if (i * i == n) d++;
}
bool isSubSequence(string str1, string str2, int m, int n, int x, int y) {
  int j = 0;
  for (int i = 0; i < n; i++)
    if (j < m && (i < x || i >= x + y) && x + y <= n && str1[j] == str2[i]) j++;
  return (j == m);
}
long long countDivisibles(long long A, long long B, long long M) {
  if (A % M == 0) return (B / M) - (A / M) + 1;
  return (B / M) - (A / M);
}
int main() {
  long long i = 0, j = 0, a = 0, b = 0, c = oo, d = 0, x = 0, y = 0, s = 0, r,
            l, p;
  string s1, s2, s3, s4;
  cin >> s1 >> s2;
  l = 0;
  for (i = 0; i < s1.size(); i++) {
    for (j = 0; j < s1.size(); j++) {
      if (isSubSequence(s2, s1, (int)s2.size(), (int)s1.size(), i, j)) {
        l = max(j, l);
      }
    }
  }
  cout << l;
  return 0;
}
