#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
const int MAX = 111111;
int A[MAX];
int B[MAX];
bool lucky[MAX / 10];
int n;
bool isLucky(int x) {
  while (x != 0) {
    int d = x % 10;
    if (d != 4 && d != 7) return false;
    x /= 10;
  }
  return true;
}
void add(int i, int val) {
  for (; i < n; i |= (i + 1)) {
    B[i] += val;
  }
}
int sum(int i) {
  if (i < 0) return 0;
  int res = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1) {
    res += B[i];
  }
  return res;
}
int sum(int L, int R) { return sum(R) - sum(L - 1); }
int main() {
  memset(A, 0, sizeof(A));
  memset(B, 0, sizeof(B));
  memset(lucky, 0, sizeof(lucky));
  for (int i = 1; i < MAX / 10; i++) {
    lucky[i] = isLucky(i);
  }
  int m;
  scanf("%d %d", &n, &m);
  for (int(i) = 0; (i) < (n); (i)++) {
    scanf("%d", &A[i]);
    if (lucky[A[i]]) {
      add(i, 1);
    }
  }
  char query[10];
  int L, R, D;
  for (int(i) = 0; (i) < (m); (i)++) {
    scanf("\n%s %d %d", query, &L, &R);
    --L, --R;
    if (query[0] == 'a') {
      scanf("%d", &D);
      for (int i = L; i <= R; i++) {
        if (lucky[A[i]]) {
          add(i, -1);
        }
        A[i] += D;
        if (lucky[A[i]]) {
          add(i, 1);
        }
      }
    } else {
      printf("%d\n", sum(L, R));
    }
  }
  return 0;
}
