#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int B[10000];
int BIT[100010];
void update(int pos, int x) {
  for (; pos < 100010; pos |= pos + 1) BIT[pos] += x;
}
int qu(int pos) {
  int ret = 0;
  for (; pos; pos &= pos - 1) ret += BIT[pos - 1];
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int len = 1; len <= 4; ++len) {
    for (int mask = 0; mask < 1 << len; ++mask) {
      int num = 0;
      for (int bit = 0; bit < len; ++bit)
        if (mask & (1 << bit))
          num = num * 10 + 4;
        else
          num = num * 10 + 7;
      B[num] = 1;
    }
  }
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (B[a[i]]) update(i, 1);
  }
  while (m--) {
    string type;
    int l, r;
    cin >> type >> l >> r;
    if (type[0] == 'c') {
      cout << qu(r) - qu(l - 1) << '\n';
    } else {
      int d;
      cin >> d;
      for (int i = l - 1; i <= r - 1; ++i) {
        if (B[a[i]]) update(i, -1);
        a[i] += d;
        if (B[a[i]]) update(i, 1);
      }
    }
  }
}
