#include <bits/stdc++.h>
using namespace std;
template <typename T, typename K>
inline bool smax(T &x, const K &y) {
  return x < y ? x = y, true : false;
}
template <typename T, typename K>
inline bool smin(T &x, const K &y) {
  return x > y ? x = y, true : false;
}
int dp[1005][55][55], pi[2][55], pc[2][55][26], n[2], m;
string t, s[2];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t, m = t.length();
  for (int i = 0; i < 2; ++i) {
    cin >> s[i], n[i] = s[i].length();
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 1; j < n[i]; ++j) {
      int k = pi[i][j - 1];
      while (k && s[i][j] != s[i][k]) k = pi[i][k - 1];
      if (s[i][j] == s[i][k]) ++k;
      pi[i][j] = k;
    }
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n[i]; ++j) {
      for (int k = 0; k < 26; ++k) {
        int l = j;
        while (l && s[i][l] - 'a' != k) l = pi[i][l - 1];
        if (s[i][l] - 'a' == k) ++l;
        pc[i][j][k] = l;
      }
    }
  }
  for (int i = 0; i < 1005; ++i) {
    for (int j = 0; j < 55; ++j) {
      for (int k = 0; k < 55; ++k) {
        dp[i][j][k] = -1e9;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n[0]; ++j) {
      for (int k = 0; k < n[1]; ++k) {
        for (int l = 0; l < 26; ++l) {
          if (t[i] == '*' || t[i] - 'a' == l) {
            int _j = pc[0][j][l], _k = pc[1][k][l], _x = 0;
            if (_j == n[0]) _x += 1, _j = pi[0][n[0] - 1];
            if (_k == n[1]) _x -= 1, _k = pi[1][n[1] - 1];
            smax(dp[i + 1][_j][_k], dp[i][j][k] + _x);
          }
        }
      }
    }
  }
  int ans = -1e9;
  for (int j = 0; j < n[0]; ++j) {
    for (int k = 0; k < n[1]; ++k) {
      smax(ans, dp[m][j][k]);
    }
  }
  cout << ans << endl;
}
