#include <bits/stdc++.h>
using namespace std;
int n, m;
int dis[10010], a[100010], sum[100010 << 2], lazy[100010 << 2],
    num[100010 << 2];
int Hiki[35] = {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};
void pushup(int u) {
  if (sum[u << 1] == sum[u << 1 | 1]) {
    sum[u] = sum[u << 1];
    num[u] = num[u << 1] + num[u << 1 | 1];
  } else if (sum[u << 1] < sum[u << 1 | 1]) {
    sum[u] = sum[u << 1];
    num[u] = num[u << 1];
  } else {
    sum[u] = sum[u << 1 | 1];
    num[u] = num[u << 1 | 1];
  }
}
void build(int u, int l, int r) {
  if (l == r) {
    sum[u] = dis[a[l]];
    num[u] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(u << 1, l, mid);
  build(u << 1 | 1, mid + 1, r);
  pushup(u);
}
void pushdown(int u) {
  if (lazy[u]) {
    sum[u << 1] += lazy[u];
    sum[u << 1 | 1] += lazy[u];
    lazy[u << 1] += lazy[u];
    lazy[u << 1 | 1] += lazy[u];
    lazy[u] = 0;
  }
}
void update(int u, int L, int R, int l, int r, int k) {
  if (L <= l && r <= R) {
    sum[u] += k;
    lazy[u] += k;
    return;
  }
  pushdown(u);
  int mid = (l + r) >> 1;
  if (L <= mid) update(u << 1, L, R, l, mid, k);
  if (mid < R) update(u << 1 | 1, L, R, mid + 1, r, k);
  pushup(u);
}
int query(int u, int L, int R, int l, int r) {
  if (sum[u]) return 0;
  if (L <= l && r <= R) return num[u];
  pushdown(u);
  int mid = (l + r) >> 1, ans = 0;
  if (L <= mid) ans += query(u << 1, L, R, l, mid);
  if (mid < R) ans += query(u << 1 | 1, L, R, mid + 1, r);
  return ans;
}
void rebuild(int u, int l, int r) {
  if (sum[u] >= 0) return;
  if (l == r) {
    a[l] -= lazy[u];
    sum[u] = dis[a[l]];
    lazy[u] = 0;
    return;
  }
  pushdown(u);
  int mid = (l + r) >> 1;
  rebuild(u << 1, l, mid);
  rebuild(u << 1 | 1, mid + 1, r);
  pushup(u);
}
int main() {
  int b, c, d, num = 0;
  char S[10];
  for (int i = 1; i <= 10000; i++) {
    if (i <= Hiki[num])
      dis[i] = Hiki[num] - i;
    else if (i > Hiki[num]) {
      num++;
      dis[i] = Hiki[num] - i;
    }
  }
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  while (m--) {
    scanf("%s", S + 1);
    if (S[1] == 'c') {
      scanf("%d%d", &b, &c);
      printf("%d\n", query(1, b, c, 1, n));
    }
    if (S[1] == 'a') {
      scanf("%d%d%d", &b, &c, &d);
      update(1, b, c, 1, n, -d);
      rebuild(1, 1, n);
    }
  }
  return 0;
}
