#include <bits/stdc++.h>
using namespace std;
int inf_int = 1e9;
long long int inf_long = 1e18;
long long int n, m, k;
string s, t;
string A, B;
int AB[100], BB[100];
bool vis[1010][55][55];
int dp[1010][55][55];
void pre(string &S, int b[]) {
  int j = -1, i = 0;
  int len = S.size();
  b[0] = j;
  while (i < len) {
    while (j >= 0 && S[i] != S[j]) j = b[j];
    i++;
    j++;
    b[i] = j;
  }
}
int f(int i, int index_A, int index_B) {
  if (i == n) return 0;
  if (vis[i][index_A][index_B]) return dp[i][index_A][index_B];
  vis[i][index_A][index_B] = true;
  int ans = -inf_int;
  for (int c = ((s[i] == '*') ? 0 : (s[i] - 'a'));
       c <= ((s[i] == '*') ? 25 : (s[i] - 'a')); c++) {
    char x = 'a' + c;
    int temp = 0;
    int index_a = index_A;
    int index_b = index_B;
    while (index_a >= 0 && x != A[index_a]) index_a = AB[index_a];
    while (index_b >= 0 && x != B[index_b]) index_b = BB[index_b];
    index_a++;
    index_b++;
    if (index_a == A.size()) {
      temp++;
      index_a = AB[index_a];
    }
    if (index_b == B.size()) {
      temp--;
      index_b = BB[index_b];
    }
    int aux = f(i + 1, index_a, index_b) + temp;
    ans = max(ans, aux);
  }
  return dp[i][index_A][index_B] = ans;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  cin >> A >> B;
  n = s.size();
  pre(A, AB);
  pre(B, BB);
  int ans = f(0, 0, 0);
  cout << ans << "\n";
  return 0;
}
