#include <bits/stdc++.h>
using namespace std;
char c[1002];
string s, t;
int dp[1001][101], root(1), cntNode(1);
bool vis[1001][101];
struct Trie {
  int son[26], fail, cnt;
  Trie() {
    for (int i = 0; i < 26; i++) son[i] = 0;
    fail = cnt = 0;
  }
} tr[105];
void add(int& a, int b) { a = a + b; }
void insert(string& s, int tag) {
  int cur = root;
  for (int i = 0; i < s.size(); i++) {
    if (!tr[cur].son[s[i] - 'a']) tr[cur].son[s[i] - 'a'] = ++cntNode;
    cur = tr[cur].son[s[i] - 'a'];
  }
  tr[cur].cnt += tag;
}
void getFail() {
  queue<int> Q;
  Q.push(root);
  tr[root].fail = root;
  while (!Q.empty()) {
    int now = Q.front();
    Q.pop();
    tr[now].cnt += tr[tr[now].fail].cnt;
    for (int i = 0; i < 26; i++) {
      if (tr[now].son[i]) {
        tr[tr[now].son[i]].fail = now != root ? tr[tr[now].fail].son[i] : root;
        Q.push(tr[now].son[i]);
      } else
        tr[now].son[i] =
            tr[tr[now].fail].son[i] ? tr[tr[now].fail].son[i] : root;
    }
  }
}
void DP() {
  for (int i = 1; i <= strlen(c + 1); i++)
    for (int j = 1; j <= cntNode; j++) dp[i][j] = INT_MIN;
  queue<pair<int, int> > Q;
  Q.push(make_pair(0, 1));
  dp[0][1] = 0;
  while (!Q.empty()) {
    int id = Q.front().first;
    int cur = Q.front().second;
    vis[id][cur] = 0;
    Q.pop();
    if (id >= strlen(c + 1)) continue;
    if (c[id + 1] == '*') {
      for (int i = 0; i < 26; i++) {
        int to = tr[cur].son[i];
        dp[id + 1][to] = max(dp[id + 1][to], dp[id][cur] + tr[to].cnt);
        if (!vis[id + 1][to]) {
          vis[id + 1][to] = 1;
          Q.push(make_pair(id + 1, to));
        }
      }
    } else {
      int to = tr[cur].son[c[id + 1] - 'a'];
      dp[id + 1][to] = max(dp[id + 1][to], dp[id][cur] + tr[to].cnt);
      if (!vis[id + 1][to]) {
        vis[id + 1][to] = 1;
        Q.push(make_pair(id + 1, to));
      }
    }
  }
}
signed main() {
  scanf("%s", c + 1);
  cin >> s >> t;
  insert(s, 1), insert(t, -1);
  getFail();
  DP();
  int ans = INT_MIN;
  for (int i = 1; i <= cntNode; i++) ans = max(ans, dp[strlen(c + 1)][i]);
  cout << ans;
  return 0;
}
