#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 17;
vector<int> lucky;
int Q[2 * N];
void add(int pos, int x) {
  pos += N;
  while (pos) {
    Q[pos] += x;
    pos >>= 1;
  }
}
int sum(int L, int R) {
  int res = 0;
  for (L += N, R += N; L < R; L >>= 1, R >>= 1) {
    if (L & 1) res += Q[L++];
    if (R & 1) res += Q[--R];
  }
  return res;
}
int find(int x) {
  if (Q[1] < x) return N - 1;
  int v = 1;
  while (v < N) {
    if (Q[2 * v] >= x)
      v = 2 * v;
    else {
      x -= Q[2 * v];
      v = 2 * v + 1;
    }
  }
  return v - N;
}
int n, m;
int a[N];
char buf[1 << 4];
vector<int> T[N], D[N];
vector<pair<int, int> > Ch[30];
int res[N];
int main() {
  lucky.push_back(4);
  lucky.push_back(7);
  for (int i = 0; i < lucky.size(); ++i) {
    int x = lucky[i] * 10 + 4;
    int y = lucky[i] * 10 + 7;
    if (x <= (int)1e4) lucky.push_back(x);
    if (y <= (int)1e4) lucky.push_back(y);
  }
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  vector<int> qL, qR, q;
  for (int i = 0; i < m; ++i) {
    scanf("%s", buf);
    int L, R, d;
    scanf("%d%d", &L, &R);
    L--;
    if (buf[0] == 'a') {
      scanf("%d", &d);
      T[L].push_back(i);
      D[L].push_back(d);
      T[R].push_back(i);
      D[R].push_back(-d);
    } else {
      qL.push_back(L);
      qR.push_back(R);
      q.push_back(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < T[i].size(); ++j) add(T[i][j], D[i][j]);
    for (int j = 0; j < lucky.size(); ++j) {
      if (lucky[j] < a[i]) continue;
      int pos = find(lucky[j] - a[i]);
      if (sum(0, pos + 1) != lucky[j] - a[i]) continue;
      Ch[j].push_back(make_pair(pos, i));
      Ch[j].push_back(make_pair(find(lucky[j] - a[i] + 1), i));
    }
  }
  for (int i = 0; i < 30; ++i) {
    memset(Q, 0, sizeof(Q));
    sort(Ch[i].begin(), Ch[i].end());
    int p = 0;
    for (int j = 0; j < q.size(); ++j) {
      while (p < Ch[i].size() && Ch[i][p].first <= q[j]) {
        if (sum(Ch[i][p].second, Ch[i][p].second + 1) == 1)
          add(Ch[i][p].second, -1);
        else
          add(Ch[i][p].second, 1);
        ++p;
      }
      res[q[j]] += sum(qL[j], qR[j]);
    }
  }
  for (int i = 0; i < q.size(); ++i) printf("%d\n", res[q[i]]);
  return 0;
}
