#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
bool lucky[N];
vector<int> aa;
void push() {
  aa = {4, 7};
  for (int i = 0; aa.back() <= 1e4; i++) {
    aa.push_back(aa[i] * 10 + 4);
    aa.push_back(aa[i] * 10 + 7);
  }
  aa.pop_back();
  aa.pop_back();
  for (auto i : aa) lucky[i] = true;
}
struct CFT {
  int n;
  vector<int> bit;
  CFT(int _n) {
    this->n = _n;
    bit.assign(_n, 0);
  }
  void update(int idx, int val) {
    while (idx <= n) {
      bit[idx] += val;
      idx += idx & (-idx);
    }
  }
  int get(int idx) {
    int ans = 0;
    while (idx > 0) {
      ans += bit[idx];
      idx -= idx & (-idx);
    }
    return ans;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  push();
  auto ft = CFT(N);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (lucky[a[i]]) ft.update(i, 1);
  }
  while (m--) {
    string s;
    cin >> s;
    if (s == "count") {
      int x, y;
      cin >> x >> y;
      cout << ft.get(y) - ft.get(x - 1) << "\n";
    } else {
      int x, y, z;
      cin >> x >> y >> z;
      for (int i = x; i <= y; i++) {
        if (lucky[a[i]]) ft.update(i, -1);
        a[i] += z;
        if (lucky[a[i]]) ft.update(i, 1);
      }
    }
  }
  return 0;
}
