#include <bits/stdc++.h>
using namespace std;
vector<long long> xs;
int n, m, a[200000], cnt[400][20000], bias[400];
void modify(int k, int d) {
  const int b = k / m;
  cnt[b][a[k]]--;
  a[k] += d;
  cnt[b][a[k]]++;
}
void add(int l, int r, int d) {
  const int lb = l / m, rb = r / m;
  if (lb == rb) {
    for (int k = l; k <= r; k++) modify(k, d);
  } else {
    for (int k = lb + 1; k < rb; k++) bias[k] += d;
    for (int k = (lb + 1) * m - 1; k >= l; k--) modify(k, d);
    for (int k = rb * m; k <= r; k++) modify(k, d);
  }
}
int kount(int l, int r) {
  const int lb = l / m, rb = r / m;
  int ans = 0;
  if (lb == rb) {
    for (int k = l; k <= r; k++) {
      if (binary_search(xs.begin(), xs.end(), bias[lb] + a[k])) ans++;
    }
  } else {
    for (int k = lb + 1; k < rb; k++) {
      for (int i = 0; i < (int)(xs.size()); i++) {
        const int t = xs[i] - bias[k];
        if (t >= 0 && t < 20000) ans += cnt[k][t];
      }
    }
    for (int k = (lb + 1) * m - 1; k >= l; k--) {
      if (binary_search(xs.begin(), xs.end(), bias[lb] + a[k])) ans++;
    }
    for (int k = rb * m; k <= r; k++) {
      if (binary_search(xs.begin(), xs.end(), bias[rb] + a[k])) ans++;
    }
  }
  return ans;
}
int main() {
  for (int k = 0; k < (int)(5); k++)
    if (k > 0) {
      const int kk = 1 << k;
      for (int b = 0; b < (int)(kk); b++) {
        long long a = 0;
        for (int i = 0; i < (int)(k); i++) a = a * 10 + (b & (1 << i) ? 7 : 4);
        xs.push_back(a);
      }
    }
  sort(xs.begin(), xs.end());
  ((void)0);
  for (int i = 0; i < (int)(xs.size()); i++) ((void)0);
  int q;
  scanf("%d%d", &n, &q);
  m = max(20, (int)sqrt(n));
  for (int i = 0; i < (int)(n); i++) scanf("%d", a + i);
  for (int i = 0; i < (int)(n); i++) cnt[i / m][a[i]]++;
  char op[8];
  int l, r, d;
  for (int _ = 0; _ < (int)(q); _++) {
    scanf(" %s%d%d", op, &l, &r);
    l--, r--;
    if (op[0] == 'a') {
      scanf("%d", &d);
      add(l, r, d);
    } else {
      printf("%d\n", kount(l, r));
    }
    for (int i = 0; i < (int)(n); i++) ((void)0), ((void)0);
  }
  return 0;
}
