#include <bits/stdc++.h>
using namespace std;
inline void chkmax(int &a, int b) { a = max(a, b); }
int n, lens, lent, nxts[51], nxtt[51], f[1003][52][52], ans = -1e9;
char c[1003], s[51], t[51];
inline void getnxt(const char *c, int len, int *nxt) {
  nxt[1] = 0;
  for (register int i = 2; i <= len; i++) {
    int j = nxt[i - 1];
    while (j && c[i] != c[j + 1]) j = nxt[j];
    if (c[i] == c[j + 1]) nxt[i] = j + 1;
  }
}
inline void calc(int x, int j, int k) {
  int jj = j;
  while (jj && c[x + 1] != s[jj + 1]) jj = nxts[jj];
  if (s[jj + 1] == c[x + 1]) ++jj;
  int kk = k;
  while (kk && c[x + 1] != t[kk + 1]) kk = nxtt[kk];
  if (t[kk + 1] == c[x + 1]) ++kk;
  if (jj == lens) {
    if (kk == lent)
      chkmax(f[x + 1][nxts[jj]][nxtt[kk]], f[x][j][k]);
    else
      chkmax(f[x + 1][nxts[jj]][kk], f[x][j][k] + 1);
  } else {
    if (kk == lent)
      chkmax(f[x + 1][jj][nxtt[kk]], f[x][j][k] - 1);
    else
      chkmax(f[x + 1][jj][kk], f[x][j][k]);
  }
}
int main() {
  scanf("%s%s%s", c + 1, s + 1, t + 1);
  n = strlen(c + 1);
  lens = strlen(s + 1);
  lent = strlen(t + 1);
  getnxt(s, lens, nxts);
  getnxt(t, lent, nxtt);
  memset(f, 0x80, sizeof f);
  f[0][0][0] = 0;
  for (register int i = 0; i < n; i++)
    if (c[i + 1] != '*')
      for (register int j = 0; j < lens; j++)
        for (register int k = 0; k < lent; k++) calc(i, j, k);
    else {
      for (c[i + 1] = 'a'; c[i + 1] <= 'z'; c[i + 1]++)
        for (register int j = 0; j < lens; j++)
          for (register int k = 0; k < lent; k++) calc(i, j, k);
      c[i + 1] = '*';
    }
  for (register int i = 0; i < lens; i++)
    for (register int j = 0; j < lent; j++) ans = max(ans, f[n][i][j]);
  printf("%d", ans);
}
