#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
vector<int> pi(string second) {
  vector<int> p(second.size());
  for (int i = 1, j = 0; i < second.size(); i++) {
    while (j and second[j] != second[i]) j = p[j - 1];
    if (second[j] == second[i]) j++;
    p[i] = j;
  }
  return p;
}
vector<int> matching(string& t, string& second) {
  vector<int> p = pi(second + '$'), match;
  for (int i = 0, j = 0; i < t.size(); i++) {
    while (j and second[j] != t[i]) j = p[j - 1];
    if (second[j] == t[i]) j++;
    if (j == second.size()) match.push_back(i - j + 1);
  }
  return match;
}
struct KMPaut : vector<vector<int>> {
  KMPaut() {}
  KMPaut(string& second)
      : vector<vector<int>>(26, vector<int>(second.size() + 1)) {
    vector<int> p = pi(second);
    auto& aut = *this;
    aut[second[0] - 'a'][0] = 1;
    for (char c = 0; c < 26; c++)
      for (int i = 1; i <= second.size(); i++)
        aut[c][i] = second[i] - 'a' == c ? i + 1 : aut[c][p[i - 1]];
  }
};
KMPaut A, B;
int dp[1010][55][55];
string x, second, t;
int rec(int a, int b, int c) {
  if (a == x.size()) return 0;
  int& ret = dp[a][b][c];
  if (ret != INF) return ret;
  if (x[a] == '*') {
    ret = -INF;
    for (int i = 0; i < 26; i++) {
      bool es, et;
      es = A[i][b] == second.size();
      et = B[i][c] == t.size();
      ret = max(ret, rec(a + 1, A[i][b], B[i][c]) + es - et);
    }
  } else {
    ret = 0;
    int es, et, at = x[a] - 'a';
    es = A[at][b] == second.size();
    et = B[at][c] == t.size();
    ret = rec(a + 1, A[at][b], B[at][c]) + es - et;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, INF, sizeof dp);
  cin >> x;
  cin >> second >> t;
  A = KMPaut(second);
  B = KMPaut(t);
  cout << rec(0, 0, 0) << '\n';
  exit(0);
}
