#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
const long long int mod = 1e9 + 7;
const long long int inf = 1e17;
struct node {
  int id, mn, cnt, lazy;
};
node seg[4 * N];
int n, a[N], lu[N];
vector<int> v;
void make(int ind) {
  seg[ind].mn = min(seg[ind * 2].mn, seg[ind * 2 + 1].mn);
  seg[ind].cnt = 0;
  seg[ind].id = n;
  if (seg[ind].mn == seg[ind * 2].mn) {
    seg[ind].cnt += seg[ind * 2].cnt;
    seg[ind].id = min(seg[ind].id, seg[ind * 2].id);
  }
  if (seg[ind].mn == seg[ind * 2 + 1].mn) {
    seg[ind].cnt += seg[ind * 2 + 1].cnt;
    seg[ind].id = min(seg[ind].id, seg[ind * 2 + 1].id);
  }
}
void upd(int val, int ind) {
  seg[ind].lazy += val;
  seg[ind].mn += val;
}
void add(int val, int l, int r, int b = 0, int e = n, int ind = 1) {
  if (l <= b && r >= e) {
    upd(val, ind);
    return;
  }
  upd(seg[ind].lazy, ind * 2);
  upd(seg[ind].lazy, ind * 2 + 1);
  seg[ind].lazy = 0;
  int mid = (b + e) / 2;
  if (l < mid) add(val, l, r, b, mid, ind * 2);
  if (r > mid) add(val, l, r, mid, e, ind * 2 + 1);
  make(ind);
}
int get(int l, int r, int b = 0, int e = n, int ind = 1) {
  if (l <= b && r >= e) {
    if (seg[ind].mn == 0) return seg[ind].cnt;
    return 0;
  }
  upd(seg[ind].lazy, ind * 2);
  upd(seg[ind].lazy, ind * 2 + 1);
  seg[ind].lazy = 0;
  int mid = (b + e) / 2, res = 0;
  if (l < mid) res += get(l, r, b, mid, ind * 2);
  if (r > mid) res += get(l, r, mid, e, ind * 2 + 1);
  make(ind);
  return res;
}
void build(int b = 0, int e = n, int ind = 1) {
  if (b + 1 == e) {
    seg[ind].id = b;
    seg[ind].cnt = 1;
    while (v[lu[b]] < a[b]) lu[b]++;
    seg[ind].mn = v[lu[b]] - a[b];
    return;
  }
  int mid = (b + e) / 2;
  build(b, mid, ind * 2);
  build(mid, e, ind * 2 + 1);
  make(ind);
}
bool lucky(int k) {
  while (k != 0) {
    if (k % 10 != 7 && k % 10 != 4) return 0;
    k /= 10;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 4; i < 1e4; i++) {
    if (lucky(i)) v.push_back(i);
  }
  build();
  while (q--) {
    string second;
    cin >> second;
    int l, r;
    cin >> l >> r;
    l--;
    if (second == "count") {
      cout << get(l, r) << endl;
      continue;
    }
    int d;
    cin >> d;
    add(-d, l, r);
    while (seg[1].mn < 0) {
      int k = seg[1].id;
      int x = lu[k];
      add(v[x + 1] - v[x], k, k + 1);
      lu[k]++;
    }
  }
  return 0;
}
