#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 10;
int ps[MAX], pt[MAX], dp[MAX][51][51];
char str[MAX], s[MAX], t[MAX];
void kmp_next(int *p, char *s) {
  p[0] = 0;
  int len = strlen(s + 1);
  for (int i = 2, j = 0; i <= len; ++i) {
    while (j > 0 && s[i] != s[j + 1]) j = p[j];
    if (s[i] == s[j + 1]) ++j;
    p[i] = j;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> (str + 1) >> (s + 1) >> (t + 1);
  kmp_next(ps, s);
  kmp_next(pt, t);
  int len = strlen(str + 1), lens = strlen(s + 1), lent = strlen(t + 1);
  int ans = -0x7fffffff;
  for (int i = 0; i <= len; ++i)
    for (int j = 0; j <= lens; ++j)
      for (int k = 0; k <= lent; ++k) dp[i][j][k] = -0x7fffffff;
  dp[0][0][0] = 0;
  for (int i = 0; i <= len; ++i)
    for (int j = 0; j <= lens; ++j)
      for (int k = 0; k <= lent; ++k)
        for (char c = 'a'; c <= 'z'; ++c)
          if (str[i + 1] == '*' || c == str[i + 1]) {
            if (dp[i][j][k] == -0x7fffffff) {
              continue;
            }
            int nj = j, nk = k;
            while (nj > 0 && c != s[nj + 1]) nj = ps[nj];
            while (nk > 0 && c != t[nk + 1]) nk = pt[nk];
            if (c == s[nj + 1]) ++nj;
            if (c == t[nk + 1]) ++nk;
            dp[i + 1][nj][nk] = max(dp[i + 1][nj][nk],
                                    dp[i][j][k] + (nj == lens) - (nk == lent));
          }
  for (int j = 0; j <= lens; ++j)
    for (int k = 0; k <= lent; ++k) {
      ans = max(ans, dp[len][j][k]);
    }
  cout << ans << endl;
}
