#include <bits/stdc++.h>
using namespace std;
int f[100005][26], l[505], r[505], pl[505], pr[505], appear[100005];
char c[100005], a[100005], opt[5];
int res, m, L, R, i, j, n;
long long ans;
inline void work(int x, int mi) {
  res -= (appear[x] >= L && appear[x] <= R);
  appear[x] += mi;
  res += (appear[x] >= L && appear[x] <= R);
}
int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  for (i = 1; i <= n; i++) {
    memcpy(f[i], f[i - 1], sizeof(f[i - 1]));
    f[i][a[i] -= 97]++;
  }
  scanf("%d%d%d", &m, &L, &R);
  for (i = 1; i <= m; i++) {
    scanf("%s%d%d", opt, &l[i], &r[i]);
    c[i] = opt[0] - 97;
    pl[i] = 0;
    pr[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    res += (!L);
    for (j = 1; j <= m; j++) {
      while (pr[j] + 1 <= i && f[i][c[j]] - f[pr[j]][c[j]] >= l[j])
        work(++pr[j], 1);
      while (pl[j] + 1 <= i && f[i][c[j]] - f[pl[j]][c[j]] > r[j])
        work(++pl[j], -1);
    }
    ans += res;
  }
  printf("%I64d", ans);
  return 0;
}
