#include <bits/stdc++.h>
using namespace std;
int dp[1005][55][55];
vector<int> z1, z2;
string s, a, b;
int solve(int idx, int i, int j) {
  if (idx == s.size()) return 0;
  if (dp[idx][i][j] != 2e9) return dp[idx][i][j];
  int ans = -1e9, x, y;
  for (char c = (s[idx] == '*' ? 'a' : s[idx]);
       c <= (s[idx] == '*' ? 'z' : s[idx]); ++c) {
    for (x = i; x > -1 and a[x] != c; x = z1[x])
      ;
    for (y = j; y > -1 and b[y] != c; y = z2[y])
      ;
    ++x, ++y;
    ans = max(ans, (x == a.size()) - (y == b.size()) +
                       solve(idx + 1, x == a.size() ? z1[x] : x,
                             y == b.size() ? z2[y] : y));
  }
  return dp[idx][i][j] = ans;
}
vector<int> build(string &s) {
  vector<int> pi(s.size() + 1, -1);
  for (int i = -1, j = 0; j < s.size(); pi[++j] = ++i)
    while (i >= 0 and s[i] != s[j]) i = pi[i];
  return pi;
}
int main() {
  fill(dp[0][0], dp[1005][0], 2e9);
  cin >> s >> a >> b;
  z1 = build(a), z2 = build(b);
  cout << solve(0, 0, 0);
}
