#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
class BIT {
  vector<i64> bit;
  int n;
  int lowbit(int x) { return x & -x; }

 public:
  void assign(int n) {
    this->n = n;
    bit.assign(n + 1, 0);
  }
  void update(int x, int v) {
    while (x <= n) {
      bit[x] += v;
      x += lowbit(x);
    }
  }
  i64 query(int x) {
    i64 res = 0;
    while (x != 0) {
      res += bit[x];
      x -= lowbit(x);
    }
    return res;
  }
  i64 query(int L, int R) { return query(R) - query(L - 1); }
};
const int maxN = 100010;
int can[] = {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, 44444};
int f[maxN];
int a[maxN];
int n, m;
BIT bit;
int main() {
  for (const int p : can) f[p] = true;
  scanf("%d%d", &n, &m);
  bit.assign(n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (f[a[i]]) bit.update(i, 1);
  }
  while (m--) {
    char s[10];
    scanf("%s", s);
    if (s[0] == 'c') {
      int L, R;
      scanf("%d%d", &L, &R);
      printf("%d\n", bit.query(L, R));
    }
    if (s[0] == 'a') {
      int L, R, val;
      scanf("%d%d%d", &L, &R, &val);
      for (int i = L; i <= R; i++) {
        if (f[a[i]] == true and f[a[i] + val] == false) bit.update(i, -1);
        if (f[a[i]] == false and f[a[i] + val] == true) bit.update(i, 1);
        a[i] += val;
      }
    }
  }
  return 0;
}
