#include <bits/stdc++.h>
using namespace std;
int p[100], lucky[10005];
int n, m, a[100050];
int ll[205], rr[205], cnt[205][10005], ans[205], off[205];
int judge(int dig) {
  if (!dig) return 0;
  while (dig) {
    if (dig % 10 != 4 && dig % 10 != 7) return false;
    dig /= 10;
  }
  return true;
}
int quary(int l, int r) {
  int nr, nl, now = 0;
  for (int i = 0; i < m; i++) {
    nl = max(ll[i], l);
    nr = min(rr[i], r);
    if (nl == ll[i] && nr == rr[i])
      now += ans[i];
    else
      while (nl <= nr) {
        now += lucky[a[nl] + off[i]];
        nl++;
      }
  }
  return now;
}
void update(int l, int r, int d) {
  int nl, nr;
  for (int i = 0; i < m; i++) {
    nl = max(ll[i], l);
    nr = min(rr[i], r);
    if (nl > nr) continue;
    if (nl == ll[i] && nr == rr[i])
      off[i] += d;
    else {
      while (nl <= nr) {
        cnt[i][a[nl]]--;
        a[nl] += d;
        cnt[i][a[nl++]]++;
      }
    }
    ans[i] = 0;
    for (int j = 1; j <= p[0]; j++)
      if (p[j] - off[i] >= 0) ans[i] += cnt[i][p[j] - off[i]];
  }
}
int main() {
  int q, l, r, d;
  char str[100];
  p[0] = 0;
  for (int i = 0; i <= 10000; i++) {
    lucky[i] = judge(i);
    if (lucky[i]) p[++p[0]] = i;
  }
  while (cin >> n >> q) {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    m = (n + 500 - 1) / 500;
    for (int i = 0; i < m; i++) {
      ll[i] = i * 500;
      rr[i] = min(n - 1, ll[i] + 500 - 1);
      off[i] = ans[i] = 0;
      for (int j = ll[i]; j <= rr[i]; j++) {
        cnt[i][a[j]]++;
        ans[i] += lucky[a[j]];
      }
    }
    while (q--) {
      scanf("%s%d%d", str, &l, &r);
      l--;
      r--;
      if (str[0] == 'c')
        printf("%d\n", quary(l, r));
      else {
        scanf("%d", &d);
        update(l, r, d);
      }
    }
  }
  return 0;
}
