#include <bits/stdc++.h>
using namespace std;
int tree[100001], a[100001], lucky[10001], n;
void dfs(int x) {
  if (x >= 10000) return;
  lucky[x] = 1;
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
void insert(int x, int v) {
  if (x == 0) return;
  while (x <= n) {
    tree[x] += v;
    x += x & -x;
  }
}
int query(int x) {
  if (x == 0) return 0;
  int an = 0;
  while (x > 0) {
    an += tree[x];
    x -= x & -x;
  }
  return an;
}
int main() {
  int i, j, k, m;
  dfs(0);
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (lucky[a[i]]) insert(i, 1);
  }
  char s[8];
  while (m--) {
    scanf("%s", s);
    if (s[0] == 'c') {
      int x, y;
      scanf("%d%d", &x, &y);
      printf("%d\n", query(y) - query(x - 1));
    } else {
      int x, y, d;
      scanf("%d%d%d", &x, &y, &d);
      for (i = x; i <= y; i++) {
        if (lucky[a[i]]) {
          insert(i, -1);
        }
        a[i] += d;
        if (lucky[a[i]]) {
          insert(i, 1);
        }
      }
    }
  }
  return 0;
}
