#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> lucky(1e5, 0);
vector<int> tree(1e5 + 5, 0);
int a[100005];
vector<int> nums;
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 low_bit(int x) { return x & (-x); }
void add(int x, int y) {
  while (x <= n) {
    tree[x] += y;
    x += low_bit(x);
  }
}
int sum(int x) {
  int temp = 0;
  while (x > 0) {
    temp += tree[x];
    x -= low_bit(x);
  }
  return temp;
}
int main() {
  lucky[4] = lucky[7] = lucky[44] = lucky[47] = lucky[74] = lucky[77] =
      lucky[444] = lucky[447] = lucky[474] = 1;
  lucky[477] = lucky[744] = lucky[747] = lucky[774] = lucky[777] = lucky[4444] =
      lucky[4447] = 1;
  lucky[4474] = lucky[4477] = lucky[4744] = lucky[4747] = lucky[4774] =
      lucky[4777] = lucky[7444] = lucky[7447] = 1;
  lucky[7474] = lucky[7477] = lucky[7744] = lucky[7747] = lucky[7774] =
      lucky[7777] = 1;
  int i, j, x, y, z;
  char s[10];
  for (i = 0; i <= n; i++) tree[i] = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int in;
    cin >> in;
    nums.push_back(in);
    a[i] = in;
    if (lucky[in]) add(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[a[j]]) add(j, -1);
        a[j] += d;
        if (lucky[a[j]]) add(j, 1);
      }
    } else {
      cout << sum(r) - sum(l - 1) << endl;
    }
  }
  return 0;
}
