#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int n;
char a[1005], s[55], t[55];
int dp[1005][105];
struct AhoCorasick {
  bool initializer = false;
  queue<int> q;
  int tr[maxn][26], cnt, val[maxn], fail[maxn];
  void insert(char *s, int d) {
    int len = strlen(s);
    int now = 0;
    for (int i = 0; i < len; ++i) {
      if (!tr[now][s[i] - 'a']) tr[now][s[i] - 'a'] = ++cnt;
      now = tr[now][s[i] - 'a'];
    }
    val[now] += d;
  }
  void build() {
    initializer = true;
    for (int i = 0; i < 26; ++i)
      if (tr[0][i]) fail[tr[0][i]] = 0, q.push(tr[0][i]);
    while (q.size()) {
      int u = q.front();
      val[u] += val[fail[u]];
      q.pop();
      for (int i = 0; i < 26; ++i) {
        if (tr[u][i])
          fail[tr[u][i]] = tr[fail[u]][i], q.push(tr[u][i]);
        else
          tr[u][i] = tr[fail[u]][i];
      }
    }
  }
  void solve() {
    memset(dp, 0xcf, sizeof dp);
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= cnt; ++j) {
        for (int c = 0; c < 26; ++c) {
          if (a[i] == '*' || a[i] == char(c + 'a')) {
            int p = tr[j][c];
            dp[i + 1][p] = max(dp[i + 1][p], dp[i][j] + val[p]);
          }
        }
      }
    }
    int ans = 0xcfcfcfcf;
    for (int i = 0; i <= cnt; ++i) ans = max(ans, dp[n][i]);
    printf("%d\n", ans);
  }
} AC;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  scanf("%s%s%s", a, s, t);
  n = strlen(a);
  AC.insert(s, 1);
  AC.insert(t, -1);
  AC.build();
  AC.solve();
  return 0;
}
