#include <bits/stdc++.h>
using namespace std;
struct st {
  int x;
  int f;
  friend int operator<(st a, st b) {
    if (a.x != b.x) {
      return a.x > b.x;
    }
    return a.f > b.f;
  }
};
st s1, s2, s3;
multiset<st> s;
long long res;
int i, j, k, n, m, x, y, z, t;
int ia, ib;
char c[100005];
char cc[5];
int a[27][100005];
int b[27];
int bg[505], en[505];
char ac[505];
int d[505 + 505];
int main() {
  scanf("%s", c);
  scanf("%d%d%d", &m, &ia, &ib);
  n = strlen(c);
  for (i = 0; i < m; i++) {
    scanf("%s%d%d", &cc, &bg[i], &en[i]);
    ac[i] = cc[0];
  }
  for (i = 0; i < n; i++) {
    x = c[i] - 'a';
    a[x][b[x]++] = i;
    k = 0;
    for (j = 0; j < m; j++) {
      x = ac[j] - 'a';
      if (b[x] >= bg[j]) {
        if (bg[j] == 0) {
          y = i * 2 + 1;
        } else {
          y = a[x][b[x] - bg[j]];
          y = y * 2 + 1;
        }
        d[k++] = y;
        if (b[x] >= en[j] + 1) {
          y = a[x][b[x] - (en[j] + 1)];
          y = y * 2;
          d[k++] = y;
        }
      }
    }
    t = 1;
    d[k++] = i * 2;
    sort(d, d + k);
    for (j = k - 1; j >= 0; j--) {
      if (d[j] % 2 == 1) {
        t++;
      } else {
        t--;
      }
      if (j == 0 || d[j - 1] / 2 != d[j] / 2) {
        if (t >= ia && t <= ib) {
          if (j == 0) {
            res += d[j] / 2 + 1;
          } else {
            res += d[j] / 2 - d[j - 1] / 2;
          }
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
