#include <bits/stdc++.h>
using namespace std;
const unsigned long long MAXN = 1e5 + 5;
const unsigned long long MAXD = 1e4 + 5;
const unsigned long long MOD = 1e9 + 7;
unsigned long long bit[MAXN];
int lucky[MAXD];
int a[MAXN];
int n, m;
void upd(int idx, int val) {
  while (idx <= n) {
    bit[idx] += val;
    idx += (idx & (-idx));
  }
}
int get(int idx) {
  int ret = 0;
  while (idx > 0) {
    ret += bit[idx];
    idx -= (idx & (-idx));
  }
  return ret;
}
vector<int> v;
void dfs(int p) {
  if (p >= 1e4) return;
  lucky[p] = 1;
  dfs(p * 10 + 4);
  dfs(p * 10 + 7);
}
int sum(int l, int r) { return get(r) - get(l - 1); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  dfs(0);
  cin >> n >> m;
  for (unsigned long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (lucky[a[i]]) upd(i, +1);
  }
  while (m--) {
    string s;
    cin >> s;
    if (s == "count") {
      int l, r;
      cin >> l >> r;
      cout << sum(l, r) << '\n';
    } else {
      int l, r, d;
      cin >> l >> r >> d;
      for (int i = l; i <= r; i++) {
        if (lucky[a[i]]) upd(i, -1);
        a[i] += d;
        if (lucky[a[i]]) upd(i, +1);
      }
    }
  }
}
