#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10;
int n, sz = 0;
int f[MAXN], ch[MAXN][30], danger[MAXN], dp[MAXN][MAXN];
char s[MAXN], t[MAXN];
void insert(char *s, int v) {
  int now = 0, len = strlen(s);
  for (int i = 0; i < len; i++) {
    int c = s[i] - 'a';
    if (!ch[now][c]) ch[now][c] = ++sz;
    now = ch[now][c];
    if (i == len - 1) danger[now] += v;
  }
}
void getFail() {
  queue<int> q;
  f[0] = 0;
  for (int c = 0; c < 26; c++) {
    int v = ch[0][c];
    if (v) q.push(v), f[v] = 0;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int c = 0; c < 26; c++) {
      int v = ch[u][c];
      if (!v) {
        ch[u][c] = ch[f[u]][c];
        continue;
      }
      q.push(v);
      int j = f[u];
      while (j && !ch[j][c]) j = f[j];
      f[v] = ch[j][c];
      danger[v] += danger[f[v]];
    }
  }
}
void clean() { memset(dp, 0xc0, sizeof dp); }
void solve() {
  clean();
  scanf("%s", s + 1), n = strlen(s + 1);
  scanf("%s", t), insert(t, 1);
  scanf("%s", t), insert(t, -1);
  getFail();
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int u = 0; u <= sz; ++u) {
      if (dp[i - 1][u] == 0xc0c0c0c0) continue;
      if (s[i] == '*') {
        for (int c = 0; c < 26; ++c) {
          int v = ch[u][c];
          dp[i][v] = max(dp[i][v], dp[i - 1][u] + danger[v]);
        }
      } else
        dp[i][ch[u][s[i] - 'a']] = max(
            dp[i][ch[u][s[i] - 'a']], dp[i - 1][u] + danger[ch[u][s[i] - 'a']]);
    }
  }
  int ans = 0xc0c0c0c0;
  for (int i = 0; i <= sz; ++i) ans = max(ans, dp[n][i]);
  printf("%d\n", ans);
}
int main() {
  solve();
  return 0;
}
