#include <bits/stdc++.h>
using namespace std;
bool lucky[(int)1e5 + 5];
int nums[(int)1e5 + 5];
class FenwickTree {
 private:
  vector<int> ft;

 public:
  FenwickTree(int n) { ft.assign(n + 1, 0); }
  int rsq(int b) {
    int sum = 0;
    for (; b > 0; b -= b & (-b)) sum += ft[b];
    return sum;
  }
  int rsq(int a, int b) { return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }
  void adjust(int k, int v) {
    for (; k < (int)ft.size(); k += k & (-k)) ft[k] += v;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) lucky[i] = false;
  lucky[4] = lucky[7] = lucky[44] = lucky[47] = lucky[74] = lucky[77] =
      lucky[444] = lucky[447] = lucky[474] = true;
  lucky[477] = lucky[744] = lucky[747] = lucky[774] = lucky[777] = lucky[4444] =
      lucky[4447] = true;
  lucky[4474] = lucky[4477] = lucky[4744] = lucky[4747] = lucky[4774] =
      lucky[4777] = lucky[7444] = lucky[7447] = true;
  lucky[7474] = lucky[7477] = lucky[7744] = lucky[7747] = lucky[7774] =
      lucky[7777] = true;
  FenwickTree tree = FenwickTree(n);
  for (int i = 1; i <= n; i++) {
    int in;
    cin >> in;
    nums[i] = in;
    if (lucky[in]) tree.adjust(i, 1);
  }
  for (int i = 0; i < m; i++) {
    string op;
    int l, r, d;
    cin >> op >> l >> r;
    if (op == "add") {
      cin >> d;
      if (d == 0) continue;
      for (int j = l; j <= r; j++) {
        if (lucky[nums[j]]) tree.adjust(j, -1);
        nums[j] += d;
        if (lucky[nums[j]]) tree.adjust(j, 1);
      }
    } else
      cout << tree.rsq(l, r) << endl;
  }
  return 0;
}
