#include <bits/stdc++.h>
using namespace std;
const int N = 2 << 18;
int tree[2 * N];
int getSum(int index) {
  int sum = 0;
  while (index > 0) {
    sum += tree[index];
    index -= index & (-index);
  }
  return sum;
}
void update(int index, int val) {
  while (index <= N) {
    tree[index] += val;
    index += index & (-index);
  }
}
int vals[N];
int lucky[10001];
int main() {
  lucky[4] = lucky[7] = lucky[44] = lucky[77] = lucky[47] = lucky[74] =
      lucky[444] = lucky[477] = lucky[447] = lucky[474] = lucky[744] =
          lucky[777] = lucky[747] = lucky[774] = lucky[4444] = lucky[4477] =
              lucky[4447] = lucky[4474] = lucky[4744] = lucky[4777] =
                  lucky[4747] = lucky[4774] = lucky[7444] = lucky[7477] =
                      lucky[7447] = lucky[7474] = lucky[7744] = lucky[7777] =
                          lucky[7747] = lucky[7774] = 1;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> vals[i];
    if (lucky[vals[i]]) {
      update(i, 1);
    }
  }
  string cmd;
  int l, r, d;
  for (int j = 0; j < m; j++) {
    cin >> cmd;
    if (cmd == "count") {
      cin >> l >> r;
      cout << getSum(r) - getSum(l - 1) << "\n";
    } else {
      cin >> l >> r >> d;
      for (int i = l; i <= r; i++) {
        int change = 0;
        if (lucky[vals[i]]) change--;
        vals[i] += d;
        if (lucky[vals[i]]) change++;
        if (change != 0) {
          update(i, change);
        }
      }
    }
  }
  return 0;
}
