#include <bits/stdc++.h>
using namespace std;
const int N = 110000, Le = 2000;
int a[N], lu[50], ln, isluc[N];
int h[600][N / 10], ad[600];
char s[10];
int main() {
  for (int i = 1; i < N / 10; i++) {
    int p = i, luc = 1;
    while (p) luc &= (p % 10 == 4 || p % 10 == 7), p /= 10;
    if (luc) lu[ln++] = i;
    isluc[i] = luc;
  }
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) {
    int id = (i - 1) / Le;
    h[id][a[i]]++;
  }
  while (q--) {
    int l, r, d;
    scanf("%s%d%d", s, &l, &r);
    int lid = (l - 1) / Le;
    int rid = (r - 1) / Le;
    if (s[0] == 'a') {
      scanf("%d", &d);
      if (lid == rid) {
        for (int i = l; i <= r; i++) h[lid][a[i]]--, a[i] += d, h[lid][a[i]]++;
      } else {
        for (int i = l; i <= (lid + 1) * Le; i++)
          h[lid][a[i]]--, a[i] += d, h[lid][a[i]]++;
        for (int i = rid * Le + 1; i <= r; i++)
          h[rid][a[i]]--, a[i] += d, h[rid][a[i]]++;
        for (int i = lid + 1; i < rid; i++) ad[i] += d;
      }
    } else {
      int ans = 0;
      if (lid == rid) {
        for (int i = l; i <= r; i++)
          if (isluc[a[i] + ad[(i - 1) / Le]]) ans++;
      } else {
        for (int i = l; i <= (lid + 1) * Le; i++)
          if (isluc[a[i] + ad[(i - 1) / Le]]) ans++;
        for (int i = rid * Le + 1; i <= r; i++)
          if (isluc[a[i] + ad[(i - 1) / Le]]) ans++;
        for (int i = lid + 1; i < rid; i++) {
          for (int j = 0; j < ln; j++)
            if (lu[j] > ad[i]) ans += h[i][lu[j] - ad[i]];
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
