#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 6;
const int sq = 300;
struct bucket {
  int cnt[10002];
  int added;
  int l, r;
  vector<int> v;
  bucket(int _l, int _r) {
    l = _l;
    r = _r;
    memset(cnt, 0, sizeof(cnt));
    added = 0;
    v.clear();
  }
};
vector<int> lucky;
vector<bucket> b;
int a[MAXN];
int n, m;
bool is_lucky[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  lucky.push_back(4);
  lucky.push_back(7);
  lucky.push_back(44);
  lucky.push_back(47);
  lucky.push_back(74);
  lucky.push_back(77);
  lucky.push_back(444);
  lucky.push_back(447);
  lucky.push_back(474);
  lucky.push_back(477);
  lucky.push_back(744);
  lucky.push_back(747);
  lucky.push_back(774);
  lucky.push_back(777);
  lucky.push_back(4444);
  lucky.push_back(4447);
  lucky.push_back(4474);
  lucky.push_back(4477);
  lucky.push_back(4744);
  lucky.push_back(4747);
  lucky.push_back(4774);
  lucky.push_back(4777);
  lucky.push_back(7444);
  lucky.push_back(7447);
  lucky.push_back(7474);
  lucky.push_back(7477);
  lucky.push_back(7744);
  lucky.push_back(7747);
  lucky.push_back(7774);
  lucky.push_back(7777);
  for (auto lc : lucky) is_lucky[lc] = 1;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (i % sq == 1) {
      b.push_back({i, i});
      b.back().v.push_back(a[i]);
      ++b.back().cnt[a[i]];
    } else {
      ++b.back().r;
      b.back().v.push_back(a[i]);
      ++b.back().cnt[a[i]];
    }
  }
  for (int i = 1; i <= m; ++i) {
    int l, r;
    string type;
    cin >> type;
    cin >> l >> r;
    if (type == "add") {
      int d;
      cin >> d;
      for (int j = 0; j < b.size(); ++j) {
        if (b[j].r < l) continue;
        if (b[j].l > r) break;
        if (b[j].l >= l && b[j].r <= r) {
          b[j].added += d;
        } else {
          for (int g = max(b[j].l, l); g <= min(b[j].r, r); ++g) {
            --b[j].cnt[a[g]];
            a[g] += d;
            ++b[j].cnt[a[g]];
          }
        }
      }
    } else {
      int ans = 0;
      for (int j = 0; j < b.size(); ++j) {
        if (b[j].r < l) continue;
        if (b[j].l > r) break;
        if (b[j].l >= l && b[j].r <= r) {
          for (auto lc : lucky) {
            if (lc >= b[j].added) {
              ans += b[j].cnt[lc - b[j].added];
            }
          }
        } else {
          for (int g = max(b[j].l, l); g <= min(b[j].r, r); ++g) {
            if (is_lucky[a[g] + b[j].added]) {
              ++ans;
            }
          }
        }
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
