#include <bits/stdc++.h>
using namespace std;
const int maxn = 100111;
const int maxv = 10011;
bool sign[maxv];
void dfs(int tot) {
  if (tot * 10 > maxv) return;
  sign[tot * 10 + 4] = 1;
  dfs(tot * 10 + 4);
  sign[tot * 10 + 7] = 1;
  dfs(tot * 10 + 7);
}
void pre() { dfs(0); }
int C[maxn];
void add(int x, int v) {
  while (x < maxn) {
    C[x] += v;
    x += (x & (-x));
  }
}
int query(int x) {
  int res = 0;
  while (x > 0) {
    res += C[x];
    x -= (x & (-x));
  }
  return res;
}
int f[maxn], used[maxn];
int main() {
  pre();
  int n, m;
  scanf("%d%d", &n, &m);
  int a, b, c;
  char op[10];
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &f[i]);
    if (sign[f[i]]) add(i, 1), used[i] = 1;
  }
  while (m--) {
    scanf("%s%d%d", op, &a, &b);
    if (op[0] == 'c') {
      printf("%d\n", query(b) - query(a - 1));
    } else {
      scanf("%d", &c);
      for (int i = (a); i <= (b); i++) {
        if (f[i] > 7780) continue;
        f[i] += c;
        if (sign[f[i]]) {
          if (!used[i]) add(i, 1), used[i] = 1;
        } else {
          if (used[i]) add(i, -1), used[i] = 0;
        }
      }
    }
  }
  return 0;
}
