#include <bits/stdc++.h>
using namespace std;
int sum[131072];
inline void add(int p, int w) {
  for (; p < 131072; p += (p & (-p))) sum[p] += w;
}
inline int interval(int f, int t) {
  int ret = 0;
  --f;
  for (; t; t -= (t & (-t))) ret += sum[t];
  for (; f; f -= (f & (-f))) ret -= sum[f];
  return ret;
}
int isLucky(int w) {
  int T;
  while (w) {
    T = w % 10;
    if (T != 4 && T != 7) return 0;
    w /= 10;
  }
  return 1;
}
int lucky[131072], in[131072], n, m;
int main() {
  for (int i = 1; i < 131072; ++i) lucky[i] = isLucky(i);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &in[i]);
    if (lucky[in[i]]) add(i, 1);
  }
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    char buf[10];
    scanf("%s", &buf);
    if (buf[0] == 'c')
      scanf("%d%d", &a, &b), printf("%d\n", interval(a, b));
    else {
      scanf("%d%d%d", &a, &b, &c);
      for (int i = a; i <= b; ++i) {
        if (lucky[in[i]] && !lucky[in[i] + c]) add(i, -1);
        if (!lucky[in[i]] && lucky[in[i] + c]) add(i, 1);
        in[i] += c;
      }
    }
  }
  return 0;
}
