#include <bits/stdc++.h>
const int MAXN = 100010;
int n, m, x;
int a[MAXN], t[MAXN],
    b[50] = {
        0,    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,
};
char s[20];
bool vis[MAXN];
inline void read(int& x) {
  int f = 1;
  register char c = getchar();
  for (x = 0; !isdigit(c); c == '-' && (f = -1), c = getchar())
    ;
  for (; isdigit(c); x = x * 10 + c - 48, c = getchar())
    ;
  x = x * f;
}
inline void add(int x, int v) {
  for (int i = x; i <= n; i += i & (-i)) t[i] += v;
}
inline int query(int x) {
  int tot = 0;
  for (int i = x; i; i -= i & (-i)) tot += t[i];
  return tot;
}
int hh() {
  int x, y, z;
  read(n);
  read(m);
  for (int i = 1; i <= 30; ++i) vis[b[i]] = true;
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    if (vis[a[i]]) add(i, 1);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%s", s);
    read(x);
    read(y);
    if (s[0] == 'a') {
      read(z);
      for (int i = x; i <= y; ++i) {
        int k = 0;
        if (vis[a[i]]) --k;
        a[i] += z;
        if (vis[a[i]]) ++k;
        if (k) add(i, k);
      }
    } else
      printf("%d\n", query(y) - query(x - 1));
  }
  return 0;
}
int sb = hh();
int main() { ; }
