#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 100;
int mn[4 * MAXN], ind[4 * MAXN], tedad[4 * MAXN], flag[4 * MAXN], a[MAXN], n, q;
vector<int> lucky;
int nemidonam[MAXN];
void update(int id) {
  if (mn[2 * id] == mn[2 * id + 1]) {
    mn[id] = mn[2 * id + 1];
    ind[id] = ind[2 * id + 1];
    tedad[id] = tedad[2 * id] + tedad[2 * id + 1];
    return;
  }
  if (mn[2 * id] < mn[2 * id + 1]) {
    mn[id] = mn[2 * id];
    ind[id] = ind[2 * id];
    tedad[id] = tedad[2 * id];
    return;
  }
  if (mn[2 * id] > mn[2 * id + 1]) {
    mn[id] = mn[2 * id + 1];
    ind[id] = ind[2 * id + 1];
    tedad[id] = tedad[2 * id + 1];
    return;
  }
}
void build(int s = 0, int e = n, int id = 1) {
  if (e - s < 2) {
    mn[id] = a[s];
    ind[id] = s;
    tedad[id] = 1;
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, 2 * id);
  build(mid, e, 2 * id + 1);
  update(id);
}
void shift(int id) {
  int x = flag[id];
  if (x == 0) return;
  flag[2 * id] += x;
  mn[2 * id] += x;
  flag[2 * id + 1] += x;
  mn[2 * id + 1] += x;
  flag[id] = 0;
}
void add(int l, int r, int val, int s = 0, int e = n, int id = 1) {
  if (e <= l or r <= s) return;
  if (l <= s && e <= r) {
    mn[id] += val;
    flag[id] += val;
    return;
  }
  shift(id);
  int mid = (s + e) / 2;
  add(l, r, val, s, mid, 2 * id);
  add(l, r, val, mid, e, 2 * id + 1);
  update(id);
}
int get(int l, int r, int s = 0, int e = n, int id = 1) {
  if (e <= l or r <= s) {
    return 0;
  }
  if (l <= s && e <= r) {
    if (mn[id] == 0)
      return tedad[id];
    else
      return 0;
  }
  shift(id);
  int mid = (s + e) / 2;
  return get(l, r, s, mid, 2 * id) + get(l, r, mid, e, 2 * id + 1);
}
int main() {
  for (int i = 1; i <= 10000; i++) {
    int x = i;
    bool check = 1;
    while (x) {
      check &= ((x % 10 == 4) or (x % 10 == 7));
      x /= 10;
    }
    if (check == 1) {
      lucky.push_back(i);
    }
  }
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    nemidonam[i] = 0;
    a[i] = 4 - a[i];
  }
  build();
  while (q--) {
    while (mn[1] < 0) {
      int pos = ind[1];
      int now = lucky[nemidonam[pos]];
      int nxt = lucky[nemidonam[pos] + 1];
      add(pos, pos + 1, nxt - now);
      nemidonam[pos]++;
    }
    string type;
    cin >> type;
    if (type == "add") {
      int l, r, x;
      cin >> l >> r >> x;
      l--;
      add(l, r, -x);
    }
    if (type == "count") {
      int l, r;
      cin >> l >> r;
      l--;
      cout << get(l, r) << endl;
      ;
    }
  }
  return 0;
}
