#include <bits/stdc++.h>
using namespace std;
long long lpss[52];
long long lpst[52];
long long nxts[52][26];
long long nxtt[52][26];
void init(string s, long long lps[], long long nxt[52][26], long long n) {
  for (long long i = (1), _b = (n - 1); i <= _b; i++) {
    long long curr = lps[i - 1];
    while (curr != 0 && s[curr] != s[i]) curr = lps[curr - 1];
    if (s[curr] == s[i]) curr++;
    lps[i] = curr;
  }
  for (long long i = (0), _b = (n); i <= _b; i++) {
    for (long long j = (0), _b = (25); j <= _b; j++) {
      char c = (char)('a' + j);
      long long curr = i;
      while (curr != 0 && s[curr] != c) curr = lps[curr - 1];
      if (s[curr] == c) curr++;
      nxt[i][j] = curr;
    }
  }
}
long long dp[1001][52][52];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string c;
  cin >> c;
  string s, t;
  cin >> s >> t;
  long long n = s.length();
  long long m = t.length();
  long long x = c.length();
  init(s, lpss, nxts, n);
  init(t, lpst, nxtt, m);
  for (long long i = (0), _b = (1000); i <= _b; i++) {
    for (long long j = (0), _b = (51); j <= _b; j++) {
      for (long long k = (0), _b = (51); k <= _b; k++) {
        dp[i][j][k] = -1000000000000000000;
      }
    }
  }
  dp[0][0][0] = 0;
  for (long long i = (0), _b = (x - 1); i <= _b; i++) {
    for (long long j = (0), _b = (n); j <= _b; j++) {
      for (long long k = (0), _b = (m); k <= _b; k++) {
        if (dp[i][j][k] == -1000000000000000000) continue;
        for (long long z = (0), _b = (25); z <= _b; z++) {
          if (c[i] == '*' || c[i] == (char)('a' + z)) {
            char xx = (char)('a' + z);
            long long nj = nxts[j][z];
            long long nk = nxtt[k][z];
            long long diff = (nj == n) - (nk == m);
            long long tmp = dp[i][j][k] + diff;
            dp[i + 1][nj][nk] = max(dp[i + 1][nj][nk], tmp);
          }
        }
      }
    }
  }
  long long ans = -1000000000000000000;
  for (long long i = (0), _b = (n); i <= _b; i++) {
    for (long long j = (0), _b = (m); j <= _b; j++) {
      ans = max(ans, dp[x][i][j]);
    }
  }
  cout << ans << endl;
}
