#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m;
int a[maxn];
int c[maxn];
int flag[10010];
int lowbit(int x) { return x & -x; }
void update(int i, int x) {
  for (; i <= n; i += lowbit(i)) c[i] += x;
}
int sum(int i) {
  int sum = 0;
  for (; i > 0; i -= lowbit(i)) sum += c[i];
  return sum;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(c, 0, sizeof c);
    memset(flag, 0, sizeof flag);
    flag[4] = flag[7] = flag[44] = flag[47] = flag[74] = flag[77] = flag[444] =
        flag[447] = flag[474] = flag[477] = flag[744] = 1;
    flag[747] = flag[774] = flag[777] = flag[4444] = flag[4447] = flag[4474] =
        flag[4477] = flag[4744] = flag[4747] = 1;
    flag[4774] = flag[4777] = flag[7444] = flag[7447] = flag[7474] =
        flag[7477] = flag[7744] = flag[7747] = flag[7774] = flag[7777] = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
      if (flag[a[i]]) update(i, 1);
    }
    char s[10];
    int aa, bb, cc;
    for (int i = 1; i <= m; i++) {
      scanf("%s", s);
      if (s[0] == 'c') {
        scanf("%d%d", &aa, &bb);
        int ans = sum(bb) - sum(aa - 1);
        printf("%d\n", ans);
      } else {
        scanf("%d%d%d", &aa, &bb, &cc);
        for (int j = aa; j <= bb; j++) {
          if (flag[a[j]]) update(j, -1);
          a[j] += cc;
          if (flag[a[j]]) update(j, 1);
        }
      }
    }
  }
  return 0;
}
