#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int dp[maxn][55][55];
int fail[maxn], go[3][maxn][30];
int inf = 1e9;
string s, t;
void kmp(int f) {
  int match = 0;
  string st;
  if (f)
    st = t;
  else
    st = s;
  for (int i = 1; i < st.size(); i++) {
    while (match > 0 && st[match] != st[i]) {
      match = fail[match];
    }
    match += (st[match] == st[i]);
    fail[i + 1] = match;
  }
  for (int i = 0; i <= st.size(); i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      if (i < st.size() && st[i] == c) {
        go[f][i][c - 'a'] = i + 1;
      } else {
        go[f][i][c - 'a'] = go[f][fail[i]][c - 'a'];
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  string c;
  cin >> c;
  cin >> s >> t;
  kmp(0);
  kmp(1);
  for (int i = 0; i <= c.size(); i++) {
    for (int j = 0; j <= s.size(); j++) {
      for (int k = 0; k <= t.size(); k++) {
        dp[i][j][k] = -inf;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < c.size(); i++) {
    for (int j = 0; j <= s.size(); j++) {
      for (int k = 0; k <= t.size(); k++) {
        if (c[i] != '*') {
          char cr = c[i];
          dp[i + 1][go[0][j][cr - 'a']][go[1][k][cr - 'a']] =
              max(dp[i + 1][go[0][j][cr - 'a']][go[1][k][cr - 'a']],
                  dp[i][j][k] + (go[0][j][cr - 'a'] == s.size()) -
                      (go[1][k][cr - 'a'] == t.size()));
        } else {
          for (char cr = 'a'; cr <= 'z'; cr++) {
            dp[i + 1][go[0][j][cr - 'a']][go[1][k][cr - 'a']] =
                max(dp[i + 1][go[0][j][cr - 'a']][go[1][k][cr - 'a']],
                    dp[i][j][k] + (go[0][j][cr - 'a'] == s.size()) -
                        (go[1][k][cr - 'a'] == t.size()));
          }
        }
      }
    }
  }
  int ans = -inf;
  for (int i = 0; i <= s.size(); i++) {
    for (int j = 0; j <= t.size(); j++) {
      ans = max(dp[c.size()][i][j], ans);
    }
  }
  cout << ans << endl;
  return 0;
}
