#include <bits/stdc++.h>
using namespace std;
struct cpp {
  int sl, val;
} sum[100005 << 2];
int n, m, cnt;
int a[100005], dis[100005], lazy[100005 << 2];
int luck[32] = {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, 44447};
void pushup(int rt) {
  if (sum[rt << 1].val == sum[rt << 1 | 1].val) {
    sum[rt].val = sum[rt << 1].val;
    sum[rt].sl = sum[rt << 1].sl + sum[rt << 1 | 1].sl;
  } else if (sum[rt << 1].val < sum[rt << 1 | 1].val) {
    sum[rt].val = sum[rt << 1].val;
    sum[rt].sl = sum[rt << 1].sl;
  } else {
    sum[rt].val = sum[rt << 1 | 1].val;
    sum[rt].sl = sum[rt << 1 | 1].sl;
  }
}
void build(int l, int r, int rt) {
  if (l == r) {
    sum[rt].val = dis[a[l]];
    sum[rt].sl = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
void pushdown(int rt) {
  if (lazy[rt] == 0) return;
  lazy[rt << 1] += lazy[rt];
  lazy[rt << 1 | 1] += lazy[rt];
  sum[rt << 1].val += lazy[rt];
  sum[rt << 1 | 1].val += lazy[rt];
  lazy[rt] = 0;
}
int query(int a, int b, int l, int r, int rt) {
  int ret = 0;
  if (sum[rt].val != 0) return 0;
  if (a <= l && r <= b) return sum[rt].sl;
  pushdown(rt);
  int mid = (l + r) >> 1;
  if (a <= mid) ret += query(a, b, l, mid, rt << 1);
  if (b > mid) ret += query(a, b, mid + 1, r, rt << 1 | 1);
  return ret;
}
void update(int a, int b, int x, int l, int r, int rt) {
  if (a <= l && r <= b) {
    sum[rt].val += x;
    lazy[rt] += x;
    return;
  }
  pushdown(rt);
  int mid = (l + r) >> 1;
  if (a <= mid) update(a, b, x, l, mid, rt << 1);
  if (b > mid) update(a, b, x, mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
void rebuild(int l, int r, int rt) {
  if (sum[rt].val >= 0) return;
  if (l == r) {
    a[l] -= lazy[rt];
    sum[rt].val = dis[a[l]];
    lazy[rt] = 0;
    return;
  }
  pushdown(rt);
  int mid = (l + r) >> 1;
  rebuild(l, mid, rt << 1);
  rebuild(mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  cnt = 0;
  for (int i = 1; i <= 10000; i++) {
    if (luck[cnt] < i) cnt++;
    dis[i] = luck[cnt] - i;
  }
  build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    char op[10];
    scanf("%s", op);
    if (op[0] == 'c') {
      int a, b;
      scanf("%d%d", &a, &b);
      printf("%d\n", query(a, b, 1, n, 1));
    } else {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      update(a, b, -c, 1, n, 1);
      rebuild(1, n, 1);
    }
  }
  return 0;
}
