#include <bits/stdc++.h>
int n, m, a[(1 << 17)], f[(1 << 17)];
bool p[(10010)];
int getSum(int x);
void modify(int x, int k);
void Init();
char str[10];
int main() {
  Init();
  for (int i = 0; i < m; i++) {
    int x, y, c;
    scanf("%s", str);
    if (str[0] == 'c') {
      scanf("%d%d", &x, &y);
      int ans = getSum(y) - getSum(x - 1);
      printf("%d\n", ans);
    } else {
      scanf("%d%d%d", &x, &y, &c);
      for (int j = x; j <= y; j++) {
        int del = p[a[j] + c] - p[a[j]];
        if (del) modify(j, del);
        a[j] += c;
      }
    }
  }
  return 0;
}
int getSum(int x) {
  int ret = 0;
  for (; x; x -= ((x) & -(x))) ret += f[x];
  return ret;
}
void modify(int x, int k) {
  for (; x <= n; x += ((x) & -(x))) f[x] += k;
}
void Init() {
  memset(p, 0x00, sizeof(p));
  p[0] = true;
  for (int i = 0; i < (10010); i++)
    if (p[i] && i * 10 < (10010)) {
      p[i * 10 + 4] = true;
      p[i * 10 + 7] = true;
    }
  p[0] = false;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (p[a[i]]) modify(i, 1);
  }
}
