#include <bits/stdc++.h>
using namespace std;
const int part = 1024;
const int sum = 10001;
const int luck = 30;
const int maxn = 100000;
int arr[part][sum];
int added[part];
char buf[100];
int n, m;
int beg[maxn];
int lucky[luck] = {4,    7,    44,   47,   74,   77,   444,  447,  474,  477,
                   744,  747,  774,  777,  4444, 4447, 4474, 4477, 4744, 4747,
                   4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777};
bool islucky[sum];
bool is_lucky(int v) { return v < 10000 && islucky[v]; }
void add(int l, int r, int d) {
  while (l <= r && l % part != 0) {
    --arr[l / part][beg[l]];
    beg[l] += d;
    ++arr[l / part][beg[l]];
    ++l;
  }
  while (l <= r && r % part != part - 1) {
    --arr[r / part][beg[r]];
    beg[r] += d;
    ++arr[r / part][beg[r]];
    --r;
  }
  while (l <= r) {
    added[l / part] += d;
    l += part;
  }
}
int count(int l, int r) {
  int ret = 0;
  while (l <= r && l % part != 0) {
    if (is_lucky(beg[l] + added[l / part])) {
      ret++;
    }
    ++l;
  }
  while (l <= r && r % part != part - 1) {
    if (is_lucky(beg[r] + added[r / part])) {
      ret++;
    }
    --r;
  }
  while (l <= r) {
    for (int i = 0; i < luck; i++) {
      int need = lucky[i] - added[l / part];
      if (need >= 0) {
        ret += arr[l / part][need];
      }
    }
    l += part;
  }
  return ret;
}
int main() {
  for (int i = 0; i < luck; i++) {
    islucky[lucky[i]] = true;
  }
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", beg + i);
    ++arr[i / part][beg[i]];
  }
  for (int i = 0; i < m; ++i) {
    scanf("%s", buf);
    if (strcmp(buf, "add") == 0) {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      add(l - 1, r - 1, d);
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      printf("%d\n", count(l - 1, r - 1));
    }
  }
  return 0;
}
