#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int64_t happy[] = {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, 1234567890};
struct node {
  int64_t _min;
  int64_t _minc;
  int64_t d;
  int64_t _happy;
};
node t[567890];
void upd(node &v, node &vl, node &vr) {
  v._min = min(vl._min, vr._min);
  v._minc =
      (vl._min == v._min ? vl._minc : 0) + (vr._min == v._min ? vr._minc : 0);
}
void build(int64_t v, int64_t tl, int64_t tr) {
  if (tl == tr) {
    t[v]._minc = 1;
    return;
  }
  int64_t tm = (tl + tr) / 2;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm + 1, tr);
}
int64_t _count(int64_t v, int64_t tl, int64_t tr, int64_t l, int64_t r,
               int64_t sub) {
  t[v].d += sub;
  t[v]._min -= sub;
  if (l > r) return 0;
  if (tl == l && tr == r) {
    return (t[v]._min == 0 ? t[v]._minc : 0);
  }
  sub = t[v].d;
  t[v].d = 0;
  int64_t tm = (tl + tr) / 2;
  return _count(v * 2, tl, tm, l, min(r, tm), sub) +
         _count(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, sub);
}
void add(int64_t v, int64_t tl, int64_t tr, int64_t l, int64_t r, int64_t val,
         int64_t sub) {
  t[v].d += sub;
  t[v]._min -= sub;
  if (l > r) return;
  if (tl == l && tr == r) {
    t[v].d += val;
    t[v]._min -= val;
    return;
  }
  sub = t[v].d;
  t[v].d = 0;
  int64_t tm = (tl + tr) / 2;
  add(v * 2, tl, tm, l, min(r, tm), val, sub);
  add(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val, sub);
  upd(t[v], t[v * 2], t[v * 2 + 1]);
}
void inc(int64_t v, int64_t tl, int64_t tr, int64_t sub) {
  t[v].d += sub;
  t[v]._min -= sub;
  if (t[v]._min >= 0) return;
  if (tl == tr) {
    while (t[v]._min < 0) {
      t[v]._min = happy[t[v]._happy++] - t[v].d;
    }
    return;
  }
  sub = t[v].d;
  t[v].d = 0;
  int64_t tm = (tl + tr) / 2;
  inc(v * 2, tl, tm, sub);
  inc(v * 2 + 1, tm + 1, tr, sub);
  upd(t[v], t[v * 2], t[v * 2 + 1]);
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int64_t n, m;
  cin >> n >> m;
  build(1, 0, n - 1);
  for (int64_t i = 0; i < n; i++) {
    int64_t x;
    cin >> x;
    add(1, 0, n - 1, i, i, x, 0);
  }
  while (m--) {
    string type;
    cin >> type;
    if (type == "add") {
      int64_t l, r, d;
      cin >> l >> r >> d;
      l--;
      r--;
      add(1, 0, n - 1, l, r, d, 0);
    } else {
      int64_t l, r;
      cin >> l >> r;
      l--;
      r--;
      inc(1, 0, n - 1, 0);
      cout << _count(1, 0, n - 1, l, r, 0) << "\n";
    }
  }
}
