#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int N, M, tmp, K;
const int sp[30] = {
    4,    7,    44,   47,   74,   77,   444,  447,  474,  477,
    744,  747,  774,  777,  4444, 4447, 4474, 4477, 4744, 4747,
    4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777,
};
bool check[10010];
int a[maxn];
int tree[maxn];
void add(int t, int x) {
  for (; t <= N; t += t & -t) {
    tree[t] += x;
  }
}
int getsum(int t) {
  int s = 0;
  for (; t; t -= t & -t) {
    s += tree[t];
  }
  return s;
}
int main() {
  for (int i = 0; i <= 29; i++) check[sp[i]] = 1;
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    if (check[x]) add(i, 1);
  }
  for (int i = 1; i <= M; i++) {
    int l, r;
    char op[20];
    scanf("%s%d%d", op, &l, &r);
    if (op[0] == 'a') {
      int d;
      scanf("%d", &d);
      for (int j = l; j <= r; j++) {
        if (check[a[j]]) add(j, -1);
        a[j] += d;
        if (check[a[j]]) add(j, 1);
      }
    } else {
      printf("%d\n", getsum(r) - getsum(l - 1));
    }
  }
  return 0;
}
