#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int luc[N], c[N], a[N];
int n, m;
void get_lucknum(int x) {
  if (x * 10 + 7 <= 10000) {
    luc[x * 10 + 7] = 1;
    get_lucknum(x * 10 + 7);
  }
  if (x * 10 + 4 <= 10000) {
    luc[x * 10 + 4] = 1;
    get_lucknum(x * 10 + 4);
  }
}
int lowbit(int x) { return (-x) & x; }
void update(int i, int value) {
  while (i <= n) {
    c[i] += value;
    i += lowbit(i);
  }
}
int sum(int n) {
  int su = 0;
  while (n) {
    su += c[n];
    n -= lowbit(n);
  }
  return su;
}
int main() {
  while (cin >> n >> m) {
    memset(luc, 0, sizeof luc);
    get_lucknum(0);
    memset(c, 0, sizeof c);
    int q;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (luc[a[i]]) update(i, 1);
    }
    char s[15];
    int l, r;
    while (m--) {
      int value;
      cin >> s;
      if (s[0] == 'c') {
        cin >> l >> r;
        cout << sum(r) - sum(l - 1) << endl;
      } else if (s[0] == 'a') {
        cin >> l >> r >> value;
        for (int i = l; i <= r; i++) {
          if (luc[a[i]]) update(i, -1);
          a[i] += value;
          if (luc[a[i]]) update(i, 1);
        }
      }
    }
  }
}
