#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5, mod = 1e9 + 9, bit = 61, sq = 1000;
const int T = (100001 + sq - 1) / sq;
vector<int> lucky;
bool isl[N] = {0};
int bid[100005], a[100005], beg[T], en[T], lazy[T] = {0};
int fq[T][N];
void create() {
  for (int d = 1; d <= 4; d++) {
    for (int mask = 0; mask < (1ll << d); mask++) {
      int curr = 0;
      for (int j = 0; j <= d - 1; j++) {
        curr = (curr * 10);
        if (mask & (1ll << j)) {
          curr += 4;
        } else {
          curr += 7;
        }
      }
      isl[curr] = 1;
      lucky.push_back(curr);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  memset(fq, 0, sizeof(fq));
  create();
  while (t--) {
    int n, q;
    cin >> n >> q;
    int j = -1;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (i % sq == 1) {
        bid[i] = ++j;
        beg[j] = i;
        en[j] = min(i + sq - 1, n);
      } else {
        bid[i] = j;
      }
      fq[j][a[i]]++;
    }
    while (q--) {
      string tp;
      int l, r;
      cin >> tp >> l >> r;
      if (tp[0] == 'c') {
        int ans = 0;
        if (bid[l] == bid[r]) {
          for (int i = l; i <= r; i++) {
            ans += isl[a[i] + lazy[bid[l]]];
          }
        } else {
          for (int i = l; i <= en[bid[l]]; i++) {
            ans += isl[a[i] + lazy[bid[l]]];
          }
          for (int i = bid[l] + 1; i <= bid[r] - 1; i++) {
            for (auto x : lucky) {
              if (x >= lazy[i]) {
                ans += fq[i][x - lazy[i]];
              }
            }
          }
          for (int i = beg[bid[r]]; i <= r; i++) {
            ans += isl[a[i] + lazy[bid[r]]];
          }
        }
        cout << ans << '\n';
      } else {
        int d;
        cin >> d;
        if (bid[l] == bid[r]) {
          for (int i = l; i <= r; i++) {
            fq[bid[i]][a[i]]--;
            fq[bid[i]][a[i] + d]++;
            a[i] += d;
          }
        } else {
          for (int i = l; i <= en[bid[l]]; i++) {
            fq[bid[i]][a[i]]--;
            fq[bid[i]][a[i] + d]++;
            a[i] += d;
          }
          for (int i = bid[l] + 1; i <= bid[r] - 1; i++) {
            lazy[i] += d;
          }
          for (int i = beg[bid[r]]; i <= r; i++) {
            fq[bid[i]][a[i]]--;
            fq[bid[i]][a[i] + d]++;
            a[i] += d;
          }
        }
      }
    }
  }
  return 0;
}
