#include <bits/stdc++.h>
using namespace std;
namespace _Template_ {
struct cww {
  cww() {
    if (1) {
      ios::sync_with_stdio(false);
      cin.tie(0);
    }
  }
} star;
template <typename T>
inline bool chmin(T& l, T r) {
  bool a = l > r;
  if (a) l = r;
  return a;
}
template <typename T>
inline bool chmax(T& l, T r) {
  bool a = l < r;
  if (a) l = r;
  return a;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& it : v) is >> it;
  return is;
}
class reverse_range {
 private:
  struct I {
    int x;
    int operator*() { return x - 1; }
    bool operator!=(I& lhs) { return x > lhs.x; }
    void operator++() { --x; }
  };
  I i, n;

 public:
  reverse_range(int n) : i({0}), n({n}) {}
  reverse_range(int i, int n) : i({i}), n({n}) {}
  I& begin() { return n; }
  I& end() { return i; }
};
class range {
 private:
  struct I {
    int x;
    int operator*() { return x; }
    bool operator!=(I& lhs) { return x < lhs.x; }
    void operator++() { ++x; }
  };
  I i, n;

 public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  I& begin() { return i; }
  I& end() { return n; }
  reverse_range operator!() { return reverse_range(*i, *n); }
};
template <typename T>
inline T& unused_var(T& v) {
  return v;
}
using LL = long long;
}  // namespace _Template_
using namespace _Template_;
int kmp_search(string S, string word, vector<int>& table) {
  int n = S.size();
  int m = word.size();
  int i = 0, j = 0;
  for (; j < n && i < m; i++, j++)
    while (i >= 0 && word[i] != S[j]) i = table[i];
  if (i == m)
    return j - m;
  else
    return -1;
}
int kmp_advance(vector<int>& table, string& word, int i, char next) {
  while (i >= 0 && word[i] != next) i = table[i];
  return i + 1;
}
vector<int> kmp_table_build(string word) {
  int n = word.size() + 1;
  vector<int> table(n, 0);
  table[0] = -1;
  for (int i = 2, j = 0; i < n;) {
    if (word[i - 1] == word[j])
      table[i++] = ++j;
    else if (j > 0)
      j = table[j];
    else
      table[i++] = 0;
  }
  return table;
}
int smap[64][64];
int tmap[64][64];
int main() {
  string c, s, t;
  cin >> c >> s >> t;
  s += '$';
  t += '$';
  for (auto& it : s) it -= 'a';
  for (auto& it : t) it -= 'a';
  vector<int> st = kmp_table_build(s);
  vector<int> tt = kmp_table_build(t);
  for (int i : range(s.size() + 1)) {
    for (char j : range(26)) {
      smap[i][(int)j] = kmp_advance(st, s, i, j);
    }
  }
  for (int i : range(t.size() + 1)) {
    for (char j : range(26)) {
      tmap[i][(int)j] = kmp_advance(tt, t, i, j);
    }
  }
  vector<vector<int> > dp(64, vector<int>(64, -1e5));
  dp[0][0] = 0;
  for (int ci : range(c.size())) {
    vector<vector<int> > nxt(64, vector<int>(64, -1e5));
    for (int i : range(s.size() + 1)) {
      for (int j : range(t.size() + 1)) {
        int bg = 0, ed = 26;
        if (c[ci] != '*') {
          bg = c[ci] - 'a';
          ed = bg + 1;
        }
        for (int nx : range(bg, ed)) {
          int ni = smap[i][nx];
          int nj = tmap[j][nx];
          int nc = dp[i][j];
          if (ni + 1 == (int)s.size()) nc++;
          if (nj + 1 == (int)t.size()) nc--;
          chmax(nxt[ni][nj], nc);
        }
      }
    }
    swap(dp, nxt);
  }
  int ret = -1e5;
  for (auto& a : dp) {
    for (int b : a) {
      chmax(ret, b);
    }
  }
  cout << ret << endl;
  return 0;
}
