#include <bits/stdc++.h>
using namespace std;
int sz = 900;
int Tree[340][10004];
int a[100005], mark[10004], add[340];
int List[] = {4,    7,    44,   47,   74,   77,   444,  447,  474,  477,
              744,  747,  774,  777,  4444, 4447, 4474, 4477, 4744, 4747,
              4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777};
void build(int num) {
  for (int i = 1; i <= num; i++) {
    int block = i / sz;
    Tree[block][a[i]]++;
  }
}
void update(int l, int r, int val) {
  int L = l / sz;
  int R = r / sz;
  while (l % sz && l <= r) {
    Tree[L][a[l]]--;
    a[l] += val;
    Tree[L][a[l]]++;
    l++;
  }
  L = l / sz;
  while (L < R) {
    add[L] += val;
    L++;
    l += sz;
  }
  while (l <= r) {
    Tree[l / sz][a[l]]--;
    a[l] += val;
    Tree[l / sz][a[l]]++;
    l++;
  }
}
int query(int l, int r) {
  int ans = 0;
  int L = l / sz;
  int R = r / sz;
  while (l % sz && l <= r) {
    int xtra = add[L];
    if (mark[a[l] + xtra]) ans++;
    l++;
  }
  L = l / sz;
  while (L < R) {
    int xtra = add[L];
    for (int i = 0; i < 30; i++) {
      int cur = List[i] - xtra;
      if (cur > 0 && Tree[L][cur]) ans += Tree[L][cur];
    }
    L++;
    l += sz;
  }
  while (l <= r) {
    int xtra = add[L];
    if (mark[a[l] + xtra]) ans++;
    l++;
  }
  return ans;
}
int main(void) {
  int num, qry;
  scanf("%d%d", &num, &qry);
  for (int i = 0; i < 30; i++) mark[List[i]] = 1;
  for (int i = 1; i <= num; i++) scanf("%d", &a[i]);
  build(num);
  for (int i = 1; i <= qry; i++) {
    char str[8];
    scanf("%s", str);
    if (str[0] == 'c') {
      int l, r;
      scanf("%d%d", &l, &r);
      int ans = query(l, r);
      printf("%d\n", ans);
    } else {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      update(l, r, d);
    }
  }
  return 0;
}
