#include <bits/stdc++.h>
using namespace std;
const int INTINF = (int)0x3f3f3f3f;
const long long int LONGINTINF = (long long int)0x3f3f3f3f3f3f3f3f;
const double DOUBLEINF = 1.38241720848787153030907987683E306;
const int INTNEG = (int)0x80808080;
const long int LONGINTNEG = (long long int)0x8080808080808080;
const double DOUBLENEG = -5.31401037251780764728375028654E303;
int dp[1050][55][55];
int nextS[55][26], nextT[55][26];
void buildKMPTable(string &w, int nextptr[][26]) {
  int m = w.size();
  vector<int> T(m + 1);
  T[0] = -1;
  T[1] = 0;
  int pos = 2;
  int cnt = 0;
  while (pos <= m) {
    if (w[pos - 1] == w[cnt]) {
      T[pos] = cnt + 1;
      pos++;
      cnt++;
    } else if (cnt) {
      cnt = T[cnt];
    } else {
      T[pos] = 0;
      pos++;
    }
  }
  for (int i = (0); i < (m + 1); i++)
    for (int c = ('a'); c < ('z' + 1); c++) {
      int d = i;
      if (d == m) d = T[d];
      while (d > -1 && w[d] != c) d = T[d];
      nextptr[i][c] = d + 1;
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.setstate(ios_base::failbit);
  string code, s, t;
  cin >> code >> s >> t;
  memset((dp), 0x80, sizeof(dp));
  dp[0][0][0] = 0;
  int ret = INTNEG;
  int n = int(code.size());
  memset((nextT), 0, sizeof(nextT));
  memset((nextS), 0, sizeof(nextS));
  buildKMPTable(t, nextT);
  buildKMPTable(s, nextS);
  for (int i = (0); i < (n + 1); i++)
    for (int sj = (0); sj < (int(s.size()) + 1); sj++)
      for (int tj = (0); tj < (int(t.size()) + 1); tj++)
        for (int c = ('a'); c < ('z' + 1); c++) {
          if (dp[i][sj][tj] == INTNEG) continue;
          if (i == n) {
            ret = max((ret), (dp[i][sj][tj]));
            continue;
          }
          if (code[i] != '*' && code[i] != c) continue;
          int ns = nextS[sj][c], nt = nextT[tj][c];
          dp[i + 1][ns][nt] = max((dp[i + 1][ns][nt]),
                                  (dp[i][sj][tj] + int(ns == int(s.size())) -
                                   int(nt == int(t.size()))));
        }
  cout << ret << '\n';
}
