#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, s[N];
int a[N], flag[N] = {0};
vector<int> lucky;
void init() {
  queue<int> que;
  que.push(4);
  que.push(7);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    flag[u] = 1;
    for (int i = 4; i <= 7; i += 3) {
      int v = u * 10 + i;
      if (v < 0 || v > 10000) continue;
      que.push(v);
    }
  }
}
void add(int x, int val) {
  for (int i = x; i <= n; i += ((i) & (-(i)))) s[i] += val;
}
int sum(int x) {
  int ret = 0;
  for (int i = x; i; i -= ((i) & (-(i)))) ret += s[i];
  return ret;
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (flag[a[i]]) add(i, 1);
  }
  while (m--) {
    char str[10];
    int l, r, d;
    scanf("%s", str);
    if (str[0] == 'c') {
      scanf("%d%d", &l, &r);
      printf("%d\n", sum(r) - sum(l - 1));
    } else {
      scanf("%d%d%d", &l, &r, &d);
      for (int i = l; i <= r; i++) {
        if (flag[a[i]]) add(i, -1);
        if (flag[a[i] + d]) add(i, 1);
        a[i] += d;
      }
    }
  }
  return 0;
}
