#include <bits/stdc++.h>
using namespace std;
int n, m;
int mark[10005], tree[100005], a[100005];
vector<int> nums;
void init() {
  mark[4] = mark[7] = mark[44] = mark[47] = 1;
  mark[74] = mark[77] = mark[444] = mark[447] = 1;
  mark[474] = mark[477] = mark[744] = mark[747] = 1;
  mark[774] = mark[777] = mark[4444] = mark[4447] = 1;
  mark[4474] = mark[4477] = mark[4744] = mark[4747] = 1;
  mark[4774] = mark[4777] = mark[7444] = mark[7447] = 1;
  mark[7474] = mark[7477] = mark[7744] = mark[7747] = 1;
  mark[7774] = mark[7777] = 1;
}
int low_bit(int x) { return x & (-x); }
void add(int x, int y) {
  while (x <= n) {
    tree[x] += y;
    x += low_bit(x);
  }
}
int sum(int x) {
  int temp = 0;
  while (x > 0) {
    temp += tree[x];
    x -= low_bit(x);
  }
  return temp;
}
int main() {
  int i, j, x, y, z;
  char s[10];
  memset(mark, 0, sizeof(mark));
  init();
  for (i = 0; i <= n; i++) tree[i] = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int in;
    cin >> in;
    nums.push_back(in);
    a[i] = in;
    if (mark[in]) add(i, 1);
  }
  for (int i = 0; i < m; i++) {
    string op;
    int l, r, d;
    cin >> op >> l >> r;
    if (op == "add") {
      cin >> d;
      if (d == 0) continue;
      for (int j = l; j <= r; j++) {
        if (mark[a[j]]) add(j, -1);
        a[j] += z;
        if (mark[a[j]]) add(j, 1);
      }
    } else {
      cout << sum(r) - sum(l - 1) << endl;
    }
  }
  return 0;
}
