#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize( \
    "O3,Ofast,no-stack-protector,unroll-loops,fast-math,-ffp-contract=off")
int n, m, sq, l, r, d;
const int maxn = (1e5 + 1), sqr = 318, maxa = 1e4 + 1;
int cnt[sqr][maxa];
bitset<maxa> Ch;
int a[maxn], sum[sqr];
vector<int> v;
void FIR();
void check(int now);
void init();
void DoTheJob();
bool chk(int now);
int main() {
  FIR();
  init();
  DoTheJob();
}
void FIR() {
  for (int i = 4; i <= 7777; i++) {
    if (chk(i)) {
      v.push_back(i);
      Ch[i] = 1;
    }
  }
  return;
}
void check(int now) {
  if (now <= maxa) {
    v.push_back(now);
  }
  return;
}
void init() {
  sort(v.begin(), v.end());
  scanf("%d%d", &n, &m);
  for (; (sq * sq) < n; sq++)
    ;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    cnt[i / sq][a[i]]++;
  }
  return;
}
void DoTheJob() {
  while (m--) {
    string s1;
    cin >> s1;
    scanf("%d%d", &l, &r);
    l--, r--;
    if (s1 == "count") {
      int ans = 0;
      for (int i = (l / sq) + 1; i < (r / sq); i++) {
        for (int j = 0; j < v.size(); j++) {
          int x = v[j];
          if (x < sum[i]) continue;
          ans += cnt[i][x - sum[i]];
        }
      }
      for (int i = l; i < n && i <= r && ((i / sq) == (l / sq)); i++) {
        if (Ch[a[i] + sum[i / sq]]) ans++;
      }
      for (int i = r;
           i >= l && i >= 0 && ((i / sq) == (r / sq) && (r / sq) != (l / sq));
           i--) {
        if (Ch[a[i] + sum[i / sq]]) ans++;
      }
      printf("%d\n", ans);
      continue;
    }
    scanf("%d", &d);
    for (int i = l; i <= r && i < n && (i / sq) == (l / sq); i++) {
      cnt[i / sq][a[i]]--;
      a[i] += d;
      cnt[i / sq][a[i]]++;
    }
    for (int i = r; i >= l && (i / sq) == (r / sq) && (r / sq) != (l / sq);
         i--) {
      cnt[i / sq][a[i]]--;
      a[i] += d;
      cnt[i / sq][a[i]]++;
    }
    for (int i = (l / sq) + 1; i < (r / sq); i++) {
      sum[i] += d;
    }
  }
  return;
}
bool chk(int now) {
  while (now) {
    if (now % 10 != 4 && now % 10 != 7) return 0;
    now /= 10;
  }
  return 1;
}
