#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 5, MX = 1e4 + 5, SQ = N / 80;
int n, m, a[N], freq[SQ][MX], add[SQ], lucky[N];
vector<int> vec;
inline bool isLucky(int x) {
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
inline int count_bucket(int p) {
  int ret = 0;
  for (int x : vec)
    if (x >= add[p]) ret += freq[p][x - add[p]];
  return ret;
}
inline int count_query(int l, int r) {
  int L = (l + SQ - 1) / SQ, R = r / SQ, res = 0;
  if (R < L) {
    for (int i = l; i <= r; i++) res += lucky[a[i] + add[R]];
  } else {
    for (int i = l; i < L * SQ; i++) res += lucky[a[i] + add[L - 1]];
    for (int i = R * SQ; i <= r; i++) res += lucky[a[i] + add[R]];
    for (int i = L; i < R; i++) res += count_bucket(i);
  }
  return res;
}
inline void add_query(int l, int r, int d) {
  int L = (l + SQ - 1) / SQ, R = r / SQ;
  if (R < L) {
    for (int i = l; i <= r; i++) freq[R][a[i]]--, a[i] += d, freq[R][a[i]]++;
  } else {
    for (int i = l; i < L * SQ; i++)
      freq[L - 1][a[i]]--, a[i] += d, freq[L - 1][a[i]]++;
    for (int i = R * SQ; i <= r; i++)
      freq[R][a[i]]--, a[i] += d, freq[R][a[i]]++;
    for (int i = L; i < R; i++) add[i] += d;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i < MX; i++)
    if (lucky[i] = isLucky(i)) vec.push_back(i);
  cin >> n >> m;
  for (int i = 0; i < n; i++) freq[i / SQ][0]++;
  for (int i = 0, x; i < n; i++) cin >> x, add_query(i, i, x);
  while (m--) {
    string type;
    cin >> type;
    if (type == "count") {
      int l, r;
      cin >> l >> r;
      cout << count_query(l - 1, r - 1) << '\n';
    } else {
      int l, r, d;
      cin >> l >> r >> d;
      add_query(l - 1, r - 1, d);
    }
  }
}
