#include <bits/stdc++.h>
using namespace std;
char c[1007], s[107];
int idx, ch[107 << 1][26], val[107 << 1], fail[107 << 1], f[1007][107 << 1];
int add_str() {
  scanf("%s", s);
  int l = strlen(s), x = 0;
  for (int i = 0; i < l; ++i) {
    if (!ch[x][s[i] - 'a']) ch[x][s[i] - 'a'] = ++idx;
    x = ch[x][s[i] - 'a'];
  }
  return x;
}
int main() {
  scanf("%s", c);
  int n = strlen(c);
  ++val[add_str()];
  --val[add_str()];
  queue<int> q, qq;
  for (int i = 0; i < 26; ++i)
    if (ch[0][i]) q.push(ch[0][i]);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < 26; ++i)
      if (ch[x][i]) {
        fail[ch[x][i]] = ch[fail[x]][i];
        q.push(ch[x][i]);
      } else
        ch[x][i] = ch[fail[x]][i];
    qq.push(x);
  }
  while (!qq.empty()) val[qq.front()] += val[fail[qq.front()]], qq.pop();
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= idx; ++j) f[i][j] = -1007;
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= idx; ++j)
      if (f[i - 1][j] > -1007)
        if (c[i - 1] != '*') {
          int k = ch[j][c[i - 1] - 'a'];
          f[i][k] = max(f[i][k], f[i - 1][j] + val[k]);
        } else
          for (int t = 0; t < 26; ++t) {
            int k = ch[j][t];
            f[i][k] = max(f[i][k], f[i - 1][j] + val[k]);
          }
  int ans = -1007;
  for (int i = 0; i <= idx; ++i) ans = max(ans, f[n][i]);
  printf("%d\n", ans);
}
