#include <bits/stdc++.h>
bool f[100001];
void Init() {
  f[4] = f[7] = f[44] = f[47] = f[74] = f[77] = f[444] = f[447] = f[474] =
      f[477] = f[744] = f[747] = f[774] = f[777] = f[4444] = f[4447] = f[4474] =
          f[4477] = f[4744] = f[4747] = f[4774] = f[4777] = f[7444] = f[7447] =
              f[7474] = f[7477] = f[7744] = f[7747] = f[7774] = f[7777] = true;
}
struct Tree {
  int d[1000000], M;
  void Build(int n) {
    for (M = 1; M <= n + 1; M <<= 1)
      ;
    memset(d, 0, sizeof(d));
  }
  void Add(int x, int v) {
    d[x + M] += v;
    for (int i = x + M >> 1; i; i >>= 1) d[i] = d[i << 1] + d[i << 1 | 1];
  }
  int Query(int l, int r) {
    int ret = 0;
    for (l += M - 1, r += M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
      if (~l & 1) ret += d[l ^ 1];
      if (r & 1) ret += d[r ^ 1];
    }
    return ret;
  }
} tr;
int a[100001];
int main() {
  Init();
  int n, m;
  scanf("%d%d", &n, &m);
  tr.Build(n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (f[a[i]]) tr.Add(i, 1);
  }
  while (m--) {
    char s[10];
    scanf("%s", s);
    if (s[0] == 'a') {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      for (int i = l; i <= r; i++) {
        if (f[a[i]]) tr.Add(i, -1);
        a[i] += d;
        if (f[a[i]]) tr.Add(i, 1);
      }
    } else if (s[0] = 'c') {
      int l, r;
      scanf("%d%d", &l, &r);
      printf("%d\n", tr.Query(l, r));
    }
  }
  return 0;
}
