#include <bits/stdc++.h>
using namespace std;
int aa[100010], n, m, flag[10010], bb[100010];
int lowbit(int t) { return t & (-t); }
void add(int x, int y) {
  for (int i = x; i <= n; i += lowbit(i)) aa[i] += y;
}
int getsum(int x) {
  int ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) ans += aa[i];
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  memset(aa, 0, sizeof(aa));
  memset(flag, 0, sizeof(flag));
  flag[4] = flag[7] = flag[44] = flag[47] = flag[74] = flag[77] = 1;
  flag[444] = flag[447] = flag[474] = flag[744] = flag[477] = flag[747] =
      flag[774] = flag[777] = 1;
  flag[4444] = flag[4447] = flag[4474] = flag[4744] = flag[7444] = flag[4477] =
      flag[4747] = flag[7447] = flag[4774] = flag[7474] = flag[7744] = 1;
  flag[4777] = flag[7477] = flag[7747] = flag[7774] = flag[7777] = 1;
  for (int a = 1; a <= n; a++) {
    scanf("%d", &bb[a]);
    if (flag[bb[a]]) {
      add(a, 1);
    }
  }
  for (int a = 1; a <= m; a++) {
    char srr[10];
    scanf("%s", srr);
    if (srr[0] == 'c') {
      int l, r, ans = 0;
      scanf("%d%d", &l, &r);
      printf("%d\n", getsum(r) - getsum(l - 1));
    } else {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      if (d == 0) {
        continue;
      }
      for (int a = l; a <= r; a++) {
        if (flag[bb[a]]) {
          add(a, -1);
        }
        bb[a] += d;
        if (flag[bb[a]]) {
          add(a, +1);
        }
      }
    }
  }
}
