#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int MXN = 1e5 + 10;
const int MXS = MXN * 4;
const int INF = 1e9;
struct DATA {
  int mini, ted, ind;
  DATA() {
    mini = ind = INF;
    ted = 0;
  }
} tohi;
int n, q;
int A[MXN], Nxt[MXN], Lazy[MXS];
vector<int> Lucky;
DATA seg[MXS];
string s;
DATA Merge(DATA a, DATA b) {
  DATA c;
  c.mini = min(a.mini, b.mini);
  c.ted += (a.ted) * (a.mini == c.mini);
  c.ted += (b.ted) * (b.mini == c.mini);
  c.ind = (a.mini == c.mini ? a.ind : b.ind);
  return c;
}
void Build(int id = 1, int s = 1, int e = n) {
  if ((e - s + 1) == 1) {
    seg[id].mini = Lucky[0] - A[s], seg[id].ted = 1, seg[id].ind = s;
    return;
  }
  Build((id * 2), s, ((s + e) / 2)), Build((id * 2 + 1), ((s + e) / 2 + 1), e);
  seg[id] = Merge(seg[(id * 2)], seg[(id * 2 + 1)]);
}
void Shift(int id, int s, int e) {
  if (!Lazy[id]) return;
  seg[id].mini += Lazy[id];
  if ((e - s + 1) > 1) {
    Lazy[(id * 2)] += Lazy[id];
    Lazy[(id * 2 + 1)] += Lazy[id];
  }
  Lazy[id] = 0;
}
void Upd(int l, int r, int x, int id = 1, int s = 1, int e = n) {
  Shift(id, s, e);
  if (e < l || s > r) return;
  if (l <= s && e <= r) {
    Lazy[id] += x;
    Shift(id, s, e);
    return;
  }
  Upd(l, r, x, (id * 2), s, ((s + e) / 2)),
      Upd(l, r, x, (id * 2 + 1), ((s + e) / 2 + 1), e);
  seg[id] = Merge(seg[(id * 2)], seg[(id * 2 + 1)]);
}
DATA Get(int l, int r, int id = 1, int s = 1, int e = n) {
  Shift(id, s, e);
  if (e < l || s > r) return tohi;
  if (l <= s && e <= r) return seg[id];
  return Merge(Get(l, r, (id * 2), s, ((s + e) / 2)),
               Get(l, r, (id * 2 + 1), ((s + e) / 2 + 1), e));
}
inline void Relax() {
  while (seg[1].mini < 0) {
    int p = seg[1].ind;
    while (seg[1].mini < 0 && seg[1].ind == p) {
      int val = Lucky[Nxt[p] + 1] - Lucky[Nxt[p]];
      Upd(p, p, val);
      Nxt[p]++;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int l = 1; l <= 4; l++) {
    for (int mask = 0; mask < (1LL << l); mask++) {
      int num = 0;
      for (int b = l - 1; ~b; b--) {
        num *= 10;
        num += ((mask >> b) & 1LL ? 7 : 4);
      }
      Lucky.push_back(num);
    }
  }
  Lucky.push_back(INF);
  Build();
  Relax();
  while (q--) {
    int l, r, x;
    cin >> s >> l >> r;
    if (s[0] == 'a') {
      cin >> x;
      Upd(l, r, -x);
      Relax();
    } else {
      DATA ans = Get(l, r);
      cout << (ans.mini == 0 ? ans.ted : 0) << '\n';
    }
  }
  return 0;
}
