#include <bits/stdc++.h>
using namespace std;
const int MX = 10000, B = 300;
vector<vector<int>> fre;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), ln, lucky(MX + 1, 0);
  for (int i = 0; i < n; ++i) cin >> a[i];
  queue<int> q;
  q.push(0);
  while (q.size()) {
    int x = q.front() * 10;
    q.pop();
    for (auto i : {4, 7}) {
      if (x + i <= MX) {
        q.push(x + i);
        ln.push_back(x + i);
        lucky[x + i] = 1;
      }
    }
  }
  const int N = n / B + 1;
  vector<int> cnt(N, 0), d(N, 0);
  fre.resize(N, vector<int>(MX + 1, 0));
  for (int i = 0; i < n; ++i) {
    fre[i / B][a[i]]++;
    if (lucky[a[i]]) cnt[i / B]++;
  }
  auto update = [&](int l, int r, int x) {
    int bl = l / B;
    for (int i = l; i <= r; ++i) {
      if (lucky[a[i] + d[bl]]) --cnt[bl];
      --fre[bl][a[i]];
      a[i] += x;
      ++fre[bl][a[i]];
      if (lucky[a[i] + d[bl]]) ++cnt[bl];
    }
  };
  while (m--) {
    string s;
    int l, r, x;
    cin >> s >> l >> r;
    --l;
    --r;
    int bl = l / B, br = r / B;
    if (s[0] == 'a') {
      cin >> x;
      if (bl == br)
        update(l, r, x);
      else {
        for (int i = bl + 1; i < br; ++i) {
          d[i] += x;
          cnt[i] = 0;
          for (int j = 0; j < (int)ln.size(); ++j) {
            if (ln[j] - d[i] >= 0) cnt[i] += fre[i][ln[j] - d[i]];
          }
        }
        update(l, (bl + 1) * B - 1, x);
        update(br * B, r, x);
      }
    } else {
      int ans = 0;
      if (bl == br) {
        for (int i = l; i <= r; ++i) ans += lucky[a[i] + d[bl]];
      } else {
        for (int i = bl + 1; i < br; ++i) ans += cnt[i];
        for (int i = l, end = (bl + 1) * B; i < end; ++i)
          ans += lucky[a[i] + d[bl]];
        for (int i = br * B; i <= r; ++i) ans += lucky[a[i] + d[br]];
      }
      cout << ans << '\n';
    }
  }
}
