#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9, MOD = INF + 7;
const int N = 1e5 + 5;
int n, a[N], nxt[N], lucky[N];
struct Node {
  int mn = INF, cnt = 0, idx = -1, lazy = 0;
} seg[4 * N];
int doLuck(int i, int x) {
  if (x > 1e4) return i;
  if (x) lucky[i] = x, i++;
  i = doLuck(i, 10 * x + 4);
  return doLuck(i, 10 * x + 7);
}
void apply(int id, int x) {
  seg[id].mn += x;
  seg[id].lazy += x;
}
void shift(int id) {
  if (seg[id].lazy == 0) return;
  apply(2 * id, seg[id].lazy);
  apply(2 * id + 1, seg[id].lazy);
  seg[id].lazy = 0;
}
Node merge(const Node &x, const Node &y) {
  Node z;
  z.mn = min(x.mn, y.mn);
  if (z.mn == y.mn) z.cnt += y.cnt, z.idx = y.idx;
  if (z.mn == x.mn) z.cnt += x.cnt, z.idx = x.idx;
  return z;
}
void build(int id = 1, int s = 0, int e = n) {
  if (e - s < 2) {
    int d = lucky[0] - a[s];
    seg[id].mn = d;
    seg[id].cnt = 1;
    seg[id].idx = s;
    return;
  }
  int md = (s + e) / 2;
  build(2 * id, s, md);
  build(2 * id + 1, md, e);
  seg[id] = merge(seg[2 * id], seg[2 * id + 1]);
}
void update(int l, int r, int x, int id = 1, int s = 0, int e = n) {
  if (l >= e || s >= r) return;
  if (l <= s && e <= r) {
    apply(id, x);
    return;
  }
  shift(id);
  int md = (s + e) / 2;
  update(l, r, x, 2 * id, s, md);
  update(l, r, x, 2 * id + 1, md, e);
  seg[id] = merge(seg[2 * id], seg[2 * id + 1]);
}
Node get(int l, int r, int id = 1, int s = 0, int e = n) {
  if (l >= e || s >= r) return Node();
  if (l <= s && e <= r) return seg[id];
  shift(id);
  int md = (s + e) / 2;
  return merge(get(l, r, 2 * id, s, md), get(l, r, 2 * id + 1, md, e));
}
void recheck() {
  if (seg[1].mn >= 0) return;
  int x = seg[1].idx;
  update(x, x + 1, lucky[nxt[x] + 1] - lucky[nxt[x]]);
  nxt[x]++;
  recheck();
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int m = doLuck(0, 0);
  sort(lucky, lucky + m);
  lucky[m] = INF;
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  build();
  while (q--) {
    recheck();
    string s;
    cin >> s;
    int l, r;
    cin >> l >> r;
    l--;
    if (s == "add") {
      int d;
      cin >> d;
      update(l, r, -d);
    } else {
      Node x = get(l, r);
      cout << (x.mn == 0) * x.cnt << "\n";
    }
  }
  return 0;
}
