#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
bool lucky[10010];
int n, m;
int a[N];
int t[N + N];
void init() {
  memset(lucky, false, sizeof(lucky));
  lucky[0] = true;
  for (int i = 1; i <= 10000; i++)
    if (i % 10 == 4 || i % 10 == 7) lucky[i] = lucky[i / 10];
}
void update(int i, int v) {
  if (!v) return;
  i += n;
  while (i >= 1) {
    t[i] += v;
    i >>= 1;
  }
}
int query(int Left, int Right) {
  int res = 0;
  Left += n;
  Right += n;
  while (Left <= Right) {
    if (Left % 2) res += t[Left];
    if ((~Right) % 2) res += t[Right];
    Left = (Left + 1) >> 1;
    Right = (Right - 1) >> 1;
  }
  return res;
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  memset(t, 0, sizeof(t));
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    update(i, lucky[a[i]]);
  }
  char x[10];
  int Left, Right, temp;
  while (m--) {
    scanf("%s", &x);
    if (strcmp(x, "count") == 0) {
      scanf("%d%d", &Left, &Right);
      Left--;
      Right--;
      printf("%d\n", query(Left, Right));
    } else {
      scanf("%d%d%d", &Left, &Right, &temp);
      Left--;
      Right--;
      for (int i = Left; i <= Right; i++) {
        a[i] += temp;
        update(i, lucky[a[i]] - lucky[a[i] - temp]);
      }
    }
  }
  return 0;
}
