#include <bits/stdc++.h>
using namespace std;
const int MOD = int(1e9) + 7;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;
const int maxn = 205;
const double eps = 1e-7;
const double pi = acos(-1.0);
char a[maxn], b[maxn];
int len1, len2;
bool check(int mid) {
  char c[maxn];
  for (int i = 0; i < len1 - mid + 1; i++) {
    int top = 0;
    for (int j = 0; j < len1; j++)
      if (j < i || j > i + mid - 1) c[top++] = a[j];
    int k = 0;
    for (int j = 0; j < len2; j++) {
      if (k == top) break;
      for (; k < top; k++) {
        if (b[j] == c[k]) {
          k++;
          break;
        }
      }
      if (j == len2 - 1 && b[j] == c[k - 1]) return true;
    }
  }
  return false;
}
int main(void) {
  scanf("%s", a);
  scanf("%s", b);
  len1 = strlen(a);
  len2 = strlen(b);
  if (len1 == len2) return 0 * printf("0");
  int res = 0;
  int l = 1, r = len1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      l = mid + 1;
      res = mid;
    } else
      r = mid - 1;
  }
  printf("%d", res);
  return 0;
}
