#include <bits/stdc++.h>
using namespace std;
const long long infll = numeric_limits<long long>::max() >> 1;
const int inf = numeric_limits<int>::max() >> 1;
const int N = 1e5 + 1;
const int M = 1e4 + 1;
const int B = 1000;
const int K = 101;
int cnt[K][M];
int lzy[K];
int ind[N];
int arr[N];
int n, q;
bool dv[N];
int lucky[30];
bool is_lucky[M];
void input() {
  cin >> n >> q;
  for (int i = 0; i <= n; i += B) {
    dv[i] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    ind[i] = i / B;
    cnt[ind[i]][arr[i]]++;
  }
}
void update(int l, int r, int d) {
  for (int i = l; i <= r;) {
    if (i + B <= r + 1 && dv[i]) {
      lzy[ind[i]] += d;
      i += B;
    } else {
      cnt[ind[i]][arr[i]]--;
      arr[i] += d;
      cnt[ind[i]][arr[i]]++;
      i++;
    }
  }
}
int query(int l, int r) {
  int res = 0;
  for (int i = l; i <= r;) {
    if (i + B <= r + 1 && dv[i]) {
      for (int e : lucky) {
        if (e <= lzy[ind[i]]) {
          continue;
        }
        res += cnt[ind[i]][e - lzy[ind[i]]];
      }
      i += B;
    } else {
      res += is_lucky[arr[i] + lzy[ind[i]]];
      i++;
    }
  }
  return res;
}
bool is_lucky_number(int x) {
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) {
      return 0;
    }
    x /= 10;
  }
  return 1;
}
void solve() {
  for (int i = 1, j = 0; i < M; ++i) {
    if (is_lucky_number(i)) {
      is_lucky[i] = 1;
      lucky[j++] = i;
    }
  }
  for (int i = 0; i < q; ++i) {
    string cmd;
    cin >> cmd;
    int l;
    cin >> l;
    int r;
    cin >> r;
    if (cmd == "count") {
      cout << query(l, r) << "\n";
    } else {
      int d;
      cin >> d;
      update(l, r, d);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  input();
  solve();
}
