#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 7;
int H, ans;
int cnt[10007][444], a[Maxn], flag[Maxn];
int mark[Maxn];
vector<int> luck;
void lucky(int p) {
  if (p > 10000) return;
  luck.push_back(p);
  mark[p] = true;
  p *= 10;
  lucky(p + 4);
  lucky(p + 7);
}
void add(int l, int r, int d) {
  int p1 = l / H;
  int p2 = r / H;
  for (int i = p1 + 1; i < p2; i++) flag[i] += d;
  if (p1 == p2) {
    for (int i = l; i <= r; i++) cnt[a[i]][p1]--, a[i] += d, cnt[a[i]][p1]++;
    return;
  }
  int L = p2 * H;
  int R = p1 * H + H - 1;
  for (int i = L; i <= r; i++) cnt[a[i]][p2]--, a[i] += d, cnt[a[i]][p2]++;
  for (int i = l; i <= R; i++) cnt[a[i]][p1]--, a[i] += d, cnt[a[i]][p1]++;
}
void Find(int l, int r) {
  int p1 = l / H;
  int p2 = r / H;
  for (int i = p1 + 1; i < p2; i++)
    for (int j = 0; j < luck.size(); j++)
      if (luck[j] - flag[i] > 0) ans += cnt[luck[j] - flag[i]][i];
  if (p1 == p2) {
    for (int i = l; i <= r; i++) ans += mark[a[i] + flag[p1]];
    return;
  }
  int L = p2 * H;
  int R = p1 * H + H - 1;
  for (int i = L; i <= r; i++) ans += mark[a[i] + flag[p2]];
  for (int i = l; i <= R; i++) ans += mark[a[i] + flag[p1]];
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  H = sqrt(n);
  for (int i = 0; i < n; i++) scanf("%d", a + i), cnt[a[i]][i / H]++;
  lucky(4);
  lucky(7);
  for (int i = 0; i < q; i++) {
    char s[10];
    scanf("%s ", s);
    int l, r, x;
    if (s[0] == 'c') {
      ans = 0;
      scanf("%d%d", &l, &r);
      l--, r--;
      Find(l, r);
      printf("%d ", ans);
    } else {
      scanf("%d%d%d", &l, &r, &x);
      l--, r--;
      add(l, r, x);
    }
  }
  return 0;
}
