#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 17;
int n, q;
int a[N];
bool lucky[N];
int it[N];
bool is_lucky(int n) {
  while (n) {
    if (n % 10 != 7 && n % 10 != 4) return false;
    n /= 10;
  }
  return true;
}
void update(int pos, int val) {
  for (; pos <= n; pos += pos & (-pos)) it[pos] += val;
}
int query(int pos) {
  int ans = 0;
  for (; pos >= 1; pos -= pos & (-pos)) ans += it[pos];
  return ans;
}
int get(int l, int r) { return query(r) - query(l - 1); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, l, r, d;
  string s;
  for (i = 1; i <= 10000; i++)
    if (is_lucky(i)) lucky[i] = true;
  cin >> n >> q;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (lucky[a[i]]) update(i, 1);
  }
  while (q--) {
    cin >> s;
    if (s[0] == 'a') {
      cin >> l >> r >> d;
      for (i = l; i <= r; i++) {
        if (lucky[a[i]]) update(i, -1);
        a[i] += d;
        if (lucky[a[i]]) update(i, 1);
      }
    } else {
      cin >> l >> r;
      cout << get(l, r) << endl;
    }
  }
  return 0;
}
