#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9, INF = 1e9;
int n, sDis[N * 4], sSum[N * 4], lazy[N * 4], a[N], q;
pair<int, int> range[4 * N];
vector<int> luckys;
bool isLucky(int x) {
  bool lucky = 1;
  while (x) lucky &= x % 10 == 4 || x % 10 == 7, x /= 10;
  return lucky;
}
void update(int id) {
  sSum[id] = sSum[id * 2] + sSum[id * 2 + 1],
  sDis[id] = min(sDis[id * 2], sDis[id * 2 + 1]);
}
void thunder(int id) {
  if (lazy[id])
    sSum[id] = 0;
  else
    return;
  if (range[id].first == range[id].second - 1) {
    if (lazy[id] < sDis[id])
      sDis[id] -= lazy[id], a[range[id].first] += lazy[id];
    else {
      int x = a[range[id].first] += lazy[id];
      int next = *upper_bound(luckys.begin(), luckys.end(), x);
      sSum[id] = isLucky(x), sDis[id] = next - x;
    }
  } else
    lazy[id * 2] += lazy[id], lazy[id * 2 + 1] += lazy[id],
        sDis[id] -= lazy[id];
  lazy[id] = 0;
}
void make(int id = 1, int l = 0, int r = N) {
  range[id] = {l, r}, sDis[id] = 4;
  if (l + 1 >= r) return;
  int mid = (l + r) / 2;
  make(id * 2, mid, r);
  make(id * 2 + 1, l, mid);
}
void go(int id) {
  thunder(id);
  if (lazy[id] < sDis[id]) return;
  if (range[id].first < range[id].second - 1)
    go(id * 2), go(id * 2 + 1), update(id);
}
void add(int l, int r, int d, int id = 1) {
  int unity = max(0, min(r, range[id].second) - max(l, range[id].first));
  if (unity == range[id].second - range[id].first) {
    lazy[id] += d, go(id), thunder(id);
    return;
  }
  thunder(id);
  if (!unity) return;
  add(l, r, d, id * 2), add(l, r, d, id * 2 + 1);
  update(id);
}
int get(int l, int r, int id = 1) {
  int unity = max(0, min(r, range[id].second) - max(l, range[id].first));
  thunder(id);
  if (unity == range[id].second - range[id].first) return sSum[id];
  if (!unity) return 0;
  int ans = get(l, r, id * 2) + get(l, r, id * 2 + 1);
  update(id);
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  for (int i = 1; i < 10000; i++)
    if (isLucky(i)) luckys.push_back(i);
  luckys.push_back(INF);
  make();
  cin >> n >> q;
  for (int i = 0, x; i < n; i++) cin >> x, add(i, i + 1, x);
  while (q--) {
    string s;
    cin >> s;
    if (s == "add") {
      int l, r, d;
      cin >> l >> r >> d;
      add(l - 1, r, d);
    } else {
      int l, r;
      cin >> l >> r;
      cout << get(l - 1, r) << '\n';
    }
  }
}
