#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
int hagga = 1e9;
int n, m;
int luck[100], p;
void lolwa(int ind, int mad) {
  if (ind > 0) {
    luck[p++] = mad;
  }
  if (ind == 4) return;
  lolwa(ind + 1, mad * 10 + 4);
  lolwa(ind + 1, mad * 10 + 7);
}
const int N = 100010;
struct node {
  int diff, lazy, pos, c0;
  node() {
    lazy = c0 = 0;
    pos = diff = hagga;
  }
};
static node tree[4 * N];
int A[N];
int nxt[11000];
inline void propa(int nod, int a, int b) {
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc + 1;
  if (tree[nod].lazy) {
    tree[nod].diff -= tree[nod].lazy;
    if (a != b) {
      tree[lc].lazy += tree[nod].lazy;
      tree[rc].lazy += tree[nod].lazy;
    }
    tree[nod].lazy = 0;
  }
}
inline void merge(node &x, node a, node b) {
  x.diff = min(a.diff, b.diff);
  x.lazy = 0;
  x.c0 = 0;
  x.pos = hagga;
  if (x.diff == a.diff) {
    x.c0 += a.c0;
    x.pos = min(x.pos, a.pos);
  }
  if (x.diff == b.diff) {
    x.c0 += b.c0;
    x.pos = min(x.pos, b.pos);
  }
}
void buildtree(int nod, int a, int b) {
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc + 1;
  if (a == b) {
    tree[nod].diff = nxt[A[a]] - A[a];
    tree[nod].pos = a;
    tree[nod].c0 = 1;
    tree[nod].lazy = 0;
    return;
  }
  tree[nod].lazy = 0;
  buildtree(lc, a, mid);
  buildtree(rc, mid + 1, b);
  merge(tree[nod], tree[lc], tree[rc]);
}
void update(int nod, int a, int b, int x, int y, int val) {
  propa(nod, a, b);
  if (a > b || a > y || b < x) {
    return;
  }
  if (x <= a && b <= y) {
    tree[nod].lazy += val;
    propa(nod, a, b);
    return;
  }
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc + 1;
  update(lc, a, mid, x, y, val);
  update(rc, mid + 1, b, x, y, val);
  merge(tree[nod], tree[lc], tree[rc]);
}
node query(int nod, int a, int b, int x, int y) {
  propa(nod, a, b);
  node sent;
  if (a > b || a > y || b < x) {
    sent.diff = hagga;
    return sent;
  }
  if (x <= a && b <= y) {
    return tree[nod];
  }
  int mid = (a + b) >> 1, lc = (nod << 1), rc = lc + 1;
  merge(sent, query(lc, a, mid, x, y), query(rc, mid + 1, b, x, y));
  return sent;
}
inline void hagdo() {
  node yo;
  while (1) {
    yo = query(1, 1, n, 1, n);
    if (yo.diff >= 0) return;
    assert(yo.pos <= n && yo.pos > 0);
    int curr = nxt[A[yo.pos]] - yo.diff;
    int nw = nxt[curr];
    int ndiff = nw - curr;
    update(1, 1, n, yo.pos, yo.pos, yo.diff - ndiff);
    A[yo.pos] = curr;
  }
}
char comm[10];
int main() {
  int i, j;
  lolwa(0, 0);
  sort(luck, luck + p);
  luck[p] = hagga;
  int tem = 0;
  for (i = 0; i <= 10000; i++) {
    while (luck[tem] < i) tem++;
    nxt[i] = luck[tem];
  }
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  buildtree(1, 1, n);
  while (m--) {
    scanf("%s", comm);
    int l, r;
    scanf("%d%d", &l, &r);
    if (comm[0] == 'a') {
      int x;
      scanf("%d", &x);
      update(1, 1, n, l, r, x);
    } else if (comm[0] == 'c') {
      hagdo();
      node ans = query(1, 1, n, l, r);
      assert(ans.diff >= 0);
      int out = (ans.diff == 0 ? ans.c0 : 0);
      printf("%d\n", out);
    }
  }
  return 0;
}
