#include <bits/stdc++.h>
int a[101000], cnt, luck[100000];
int sum[101000], n, m;
char s[40000];
void add(int x, int y) {
  for (; x <= n; x += x & (-x)) sum[x] += y;
}
int ask(int x) {
  int ans = 0;
  for (; x; x -= x & (-x)) ans += sum[x];
  return ans;
}
inline void dfs(long long x) {
  if (x > 1e4) return;
  luck[x]++;
  dfs(1ll * x * 10 + 4);
  dfs(1ll * x * 10 + 7);
}
int main() {
  dfs(0);
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (luck[a[i]]) add(i, 1);
  }
  while (m--) {
    scanf(" %s", s + 1);
    if (s[1] == 'c') {
      int l, r;
      scanf("%d %d", &l, &r);
      printf("%d\n", ask(r) - ask(l - 1));
    } else {
      int l, r, d;
      scanf("%d %d %d", &l, &r, &d);
      for (int i = l; i <= r; ++i) {
        int w = a[i];
        a[i] += d;
        if (luck[a[i]] && !luck[w]) {
          add(i, 1);
        }
        if (luck[w] && !luck[a[i]]) {
          add(i, -1);
        }
      }
    }
  }
  return 0;
}
