#include <bits/stdc++.h>
using namespace std;
int c[100100];
int a[100100];
int n, m;
bool luck[100100] = {false};
void init() {
  luck[4] = luck[7] = luck[44] = luck[47] = luck[74] = luck[77] = luck[444] =
      luck[447] = luck[474] = luck[744] = luck[477] = luck[747] = luck[774] =
          luck[777] = luck[4444] = luck[4447] = luck[4474] = luck[4744] =
              luck[7444] = luck[4477] = luck[4747] = luck[7447] = luck[4774] =
                  luck[7474] = luck[7744] = luck[4777] = luck[7477] =
                      luck[7747] = luck[7774] = luck[7777] = 1;
}
int lowBit(int x) { return x & (-x); }
void update(int x, int v) {
  while (x <= n) {
    c[x] += v;
    x += lowBit(x);
  }
}
int sum(int num) {
  int summ;
  summ = 0;
  while (num > 0) {
    summ += c[num];
    num -= lowBit(num);
  }
  return summ;
}
int main() {
  init();
  char st[10];
  int temp, under1, under2, ad;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (luck[a[i]]) update(i, 1);
  }
  while (m--) {
    scanf("%s%d%d", st, &under1, &under2);
    if (st[0] == 'c')
      printf("%d\n", sum(under2) - sum(under1 - 1));
    else {
      scanf("%d", &ad);
      if (ad == 0) continue;
      for (int i = under1; i <= under2; i++) {
        if (luck[a[i]] == 0 && luck[a[i] + ad] == 1) {
          update(i, 1);
        } else if (luck[a[i]] == 1 && luck[a[i] + ad] == 0) {
          update(i, -1);
        }
        a[i] += ad;
      }
    }
  }
  return 0;
}
