#include <bits/stdc++.h>
using namespace std;
const int MAXN = 103;
long long where[2][MAXN][26], n, m, k;
string s, t1, t2;
long long dp[1001][MAXN][MAXN];
void build(string &s, int t) {
  int lps = 0;
  where[t][0][s[0] - 'a'] = 1;
  for (int i = 1, ThxDem = ((int)(s).size()) + 1; i < ThxDem; ++i) {
    for (int j = 0, ThxDem = 26; j < ThxDem; ++j)
      where[t][i][j] = where[t][lps][j];
    if (i < ((int)(s).size())) {
      where[t][i][s[i] - 'a'] = i + 1;
      lps = where[t][lps][s[i] - 'a'];
    }
  }
}
bool vis[1001][MAXN][MAXN];
long long solve(int pos, int p1, int p2) {
  if (pos == k) {
    int ans = (p1 == n) - (p2 == m);
    return ans;
  }
  long long &r = dp[pos][p1][p2];
  if (vis[pos][p1][p2]) return r;
  vis[pos][p1][p2] = 1;
  r = -1e10;
  int now = (p1 == n) - (p2 == m);
  if (s[pos] == '*') {
    for (int i = 0, ThxDem = 26; i < ThxDem; ++i)
      r = max(r, now + solve(pos + 1, where[0][p1][i], where[1][p2][i]));
  } else
    r = now +
        solve(pos + 1, where[0][p1][s[pos] - 'a'], where[1][p2][s[pos] - 'a']);
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> t1 >> t2;
  k = ((int)(s).size());
  n = ((int)(t1).size());
  m = ((int)(t2).size());
  build(t1, 0);
  build(t2, 1);
  cout << solve(0, 0, 0) << endl;
}
