#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int M = 55;
const int K = 26;
const int Inf = 1e8;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
int Dp1[N][K];
int Dp2[N][K];
void KMP(string t, int Type) {
  int m = t.size();
  vector<int> LongestPrefix(m);
  for (int i = 1, k = 0; i < m; i++) {
    while (k > 0 && t[i] != t[k]) k = LongestPrefix[k - 1];
    if (t[i] == t[k])
      LongestPrefix[i] = ++k;
    else
      LongestPrefix[i] = k;
  }
  for (int i = 0; i < m; i++)
    for (char c = 'a'; c <= 'z'; c++)
      if (Type == 1)
        Dp1[i][c - 'a'] =
            ((t[i] == c) ? i + 1
                         : (i ? Dp1[LongestPrefix[i - 1]][c - 'a'] : 0));
      else
        Dp2[i][c - 'a'] =
            ((t[i] == c) ? i + 1
                         : (i ? Dp2[LongestPrefix[i - 1]][c - 'a'] : 0));
  for (char c = 'a'; c <= 'z'; c++)
    if (Type == 1)
      Dp1[m][c - 'a'] = Dp1[LongestPrefix[m - 1]][c - 'a'];
    else
      Dp2[m][c - 'a'] = Dp2[LongestPrefix[m - 1]][c - 'a'];
}
int n;
char s[N];
int Dp[N][M][M];
string t1, t2;
int Rec(int i, int k1, int k2) {
  if (i == n) return 0;
  if (Dp[i][k1][k2] != Inf) return Dp[i][k1][k2];
  int Res = -Inf;
  for (char j = 'a'; j <= 'z'; j++)
    if (s[i] == '*' || s[i] == j) {
      int z1 = Dp1[k1][j - 'a'];
      int z2 = Dp2[k2][j - 'a'];
      int Res1 = (z1 == t1.size());
      int Res2 = (z2 == t2.size());
      Res = max(Res, Res1 - Res2 + Rec(i + 1, z1, z2));
    }
  return Dp[i][k1][k2] = Res;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  cin >> t1 >> t2;
  KMP(t1, 1);
  KMP(t2, 2);
  for (int i = 0; i < N; i++)
    for (int k1 = 0; k1 < M; k1++)
      for (int k2 = 0; k2 < M; k2++) Dp[i][k1][k2] = -Inf;
  for (int k1 = 0; k1 < M; k1++)
    for (int k2 = 0; k2 < M; k2++) Dp[n][k1][k2] = 0;
  for (int i = n - 1; ~i; i--)
    for (int k1 = 0; k1 <= t1.size(); k1++)
      for (int k2 = 0; k2 <= t2.size(); k2++) {
        int& Res = Dp[i][k1][k2];
        for (char j = 'a'; j <= 'z'; j++)
          if (s[i] == '*' || s[i] == j) {
            int z1 = Dp1[k1][j - 'a'];
            int z2 = Dp2[k2][j - 'a'];
            int Res1 = (z1 == t1.size());
            int Res2 = (z2 == t2.size());
            Res = max(Res, Res1 - Res2 + Dp[i + 1][z1][z2]);
          }
      }
  cout << Dp[0][0][0];
}
