#include <bits/stdc++.h>
using namespace std;
string s, a, b;
int n, x, y, prvi[55][30], drugi[55][30], dp[1005][55][55];
const int inf = (int)1e8;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  cin >> a;
  cin >> b;
  n = (int)s.size();
  x = (int)a.size();
  y = (int)b.size();
  for (int i = 0; i <= x; ++i) {
    for (int j = 0; j < 26; ++j) {
      string t = a.substr(0, i) + (char)(j + 'a');
      for (int v = min(x, i + 1); v > 0; --v) {
        if (t.substr((int)t.size() - v) == a.substr(0, v)) {
          prvi[i][j] = v;
          break;
        }
      }
    }
  }
  for (int i = 0; i <= y; ++i) {
    for (int j = 0; j < 26; ++j) {
      string t = b.substr(0, i) + (char)(j + 'a');
      for (int v = min(y, i + 1); v > 0; --v) {
        if (t.substr((int)t.size() - v) == b.substr(0, v)) {
          drugi[i][j] = v;
          break;
        }
      }
    }
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= x; ++j) {
      for (int v = 0; v <= y; ++v) {
        dp[i][j][v] = -inf;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= x; ++j) {
      for (int v = 0; v <= y; ++v) {
        if (s[i - 1] == '*') {
          for (int c = 0; c < 26; ++c) {
            dp[i][prvi[j][c]][drugi[v][c]] =
                max(dp[i][prvi[j][c]][drugi[v][c]],
                    dp[i - 1][j][v] + (prvi[j][c] == x) - (drugi[v][c] == y));
          }
        } else {
          int c = s[i - 1] - 'a';
          dp[i][prvi[j][c]][drugi[v][c]] =
              max(dp[i][prvi[j][c]][drugi[v][c]],
                  dp[i - 1][j][v] + (prvi[j][c] == x) - (drugi[v][c] == y));
        }
      }
    }
  }
  int sol = -inf;
  for (int j = 0; j <= x; ++j) {
    for (int v = 0; v <= y; ++v) {
      sol = max(sol, dp[n][j][v]);
    }
  }
  cout << sol << endl;
  return 0;
}
