#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005, inf = 1e9;
int d[maxn][55][55], next1[55], next2[55];
char c[maxn], s[55], t[55];
int n, m1, m2;
void init() {
  int len;
  len = strlen(s);
  next1[0] = -1;
  for (int i = 0, j = -1; i < len;) {
    if (j == -1 || s[j] == s[i])
      next1[++i] = ++j;
    else
      j = next1[j];
  }
  len = strlen(t);
  next2[0] = -1;
  for (int i = 0, j = -1; i < len;) {
    if (j == -1 || t[i] == t[j])
      next2[++i] = ++j;
    else
      j = next2[j];
  }
}
int get(int j, char str) {
  while (1) {
    if (j == -1 || str == s[j])
      return j + 1;
    else
      j = next1[j];
  }
}
int get1(int j, char str) {
  while (1) {
    if (j == -1 || str == t[j])
      return j + 1;
    else
      j = next2[j];
  }
}
int main() {
  scanf("%s%s%s", c + 1, s, t);
  init();
  n = strlen(c + 1), m1 = strlen(s), m2 = strlen(t);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < m1; j++)
      for (int k = 0; k < m2; k++) {
        d[i][j][k] = -inf;
      }
  d[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m1; j++)
      for (int k = 0; k < m2; k++) {
        if (d[i][j][k] == -inf) continue;
        if (c[i + 1] != '*') {
          int flag = 0;
          int j0 = get(j, c[i + 1]);
          int k0 = get1(k, c[i + 1]);
          if (j0 == m1) ++flag, j0 = next1[j0];
          if (k0 == m2) --flag, k0 = next2[k0];
          d[i + 1][j0][k0] = max(d[i + 1][j0][k0], d[i][j][k] + flag);
        } else {
          for (char y = 'a'; y <= 'z'; y++) {
            int flag = 0;
            int j0 = get(j, y);
            int k0 = get1(k, y);
            if (j0 == m1) ++flag, j0 = next1[j0];
            if (k0 == m2) --flag, k0 = next2[k0];
            d[i + 1][j0][k0] = max(d[i + 1][j0][k0], d[i][j][k] + flag);
          }
        }
      }
  }
  int ans = -inf;
  for (int i = 0; i < m1; i++)
    for (int j = 0; j < m2; j++) ans = max(ans, d[n][i][j]);
  cout << ans << '\n';
}
