#include <bits/stdc++.h>
using namespace std;
int n, ns, nt;
char c[1005], s[55], t[55];
int kmps[55], kmpt[55];
int nxtt[55][27], nxts[55][27];
int dp[1005][55][55];
void KMP(char a[], int kmp[], int nxt[][27], int sz) {
  kmp[1] = 0;
  for (int i = 2; i <= sz; i++) {
    int nr = kmp[i - 1];
    while (nr > 0 && a[nr + 1] != a[i]) {
      nr = kmp[nr];
    }
    if (a[nr + 1] == a[i]) {
      nr++;
    }
    kmp[i] = nr;
  }
  for (int i = 0; i <= sz; i++) {
    for (char ch = 'a'; ch <= 'z'; ch++) {
      int nr = i;
      while (nr > 0 && a[nr + 1] != ch) {
        nr = kmp[nr];
      }
      if (a[nr + 1] == ch) {
        nr++;
      }
      nxt[i][ch - 'a'] = nr;
    }
  }
}
int main() {
  cin >> (c + 1);
  cin >> (s + 1);
  cin >> (t + 1);
  n = strlen(c + 1);
  ns = strlen(s + 1);
  nt = strlen(t + 1);
  KMP(s, kmps, nxts, ns);
  KMP(t, kmpt, nxtt, nt);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= ns; j++) {
      for (int d = 0; d <= nt; d++) {
        dp[i][j][d] = -100000000;
      }
    }
  }
  dp[0][0][0] = 0;
  int sol = -100000000;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= ns; j++) {
      for (int d = 0; d <= nt; d++) {
        if (i != n) {
          for (char ch = 'a'; ch <= 'z'; ch++) {
            if (c[i + 1] == ch || c[i + 1] == '*') {
              int nexts = nxts[j][ch - 'a'];
              int nextt = nxtt[d][ch - 'a'];
              int p = (nexts == ns) - (nextt == nt);
              dp[i + 1][nexts][nextt] =
                  max(dp[i + 1][nexts][nextt], dp[i][j][d] + p);
            }
          }
        } else {
          sol = max(sol, dp[i][j][d]);
        }
      }
    }
  }
  cout << sol;
}
