#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const int pod = (1 << 17);
int e[N];
void add(int x, int d) {
  for (; x < N; x += (x & -x)) e[x] += d;
}
int query(int x) {
  int res = 0;
  for (; x; x -= (x & -x)) res += e[x];
  return res;
}
pair<int, int> tree[2 * pod];
int lazy[2 * pod];
void init() {
  for (int i = 1; i <= 2 * pod - 1; ++i) tree[i] = {-1e9, 0};
}
void push(int v) {
  for (int u : {2 * v, 2 * v + 1}) {
    lazy[u] += lazy[v];
    tree[u].first += lazy[v];
  }
  lazy[v] = 0;
}
void ustaw(int x, int z, int v = 1, int l = 0, int r = pod - 1) {
  if (l == r) {
    assert(z < 0);
    tree[v] = {z, l};
    return;
  }
  push(v);
  int m = (l + r) / 2;
  if (x <= m) ustaw(x, z, 2 * v, l, m);
  if (m < x) ustaw(x, z, 2 * v + 1, m + 1, r);
  tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}
void add(int x, int y, int z, int v = 1, int l = 0, int r = pod - 1) {
  if (x <= l && r <= y) {
    tree[v].first += z;
    lazy[v] += z;
    return;
  }
  push(v);
  int m = (l + r) / 2;
  if (x <= m) add(x, y, z, 2 * v, l, m);
  if (m < y) add(x, y, z, 2 * v + 1, m + 1, r);
  tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}
int n, m;
int t[N];
int a, b, c;
int g[N], ok[N];
bool good(int x) {
  while (x > 0) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
set<int> s;
vector<int> del;
int main() {
  init();
  int last = 1e4 + 10;
  for (int i = 10000; 1 <= i; --i) {
    g[i] = last;
    if (good(i)) {
      ok[i] = 1;
      last = i;
    }
  }
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", t + i);
    if (good(t[i])) {
      s.insert(i);
      add(i, 1);
    }
    ustaw(i, t[i] - g[t[i]]);
  }
  while (m--) {
    char sa[20];
    scanf("%s", sa);
    if (sa[0] == 'c') {
      scanf("%d%d", &a, &b);
      printf("%d\n", query(b) - query(a - 1));
    } else {
      del.clear();
      scanf("%d%d%d\n", &a, &b, &c);
      auto it = s.lower_bound(a);
      while (it != s.end() && *it <= b) {
        add(*it, -1);
        del.push_back(*it);
        it++;
      }
      for (auto it : del) s.erase(it);
      add(a, b, c);
      while (tree[1].first >= 0) {
        int pos = tree[1].second;
        t[pos] = g[t[pos]] + tree[1].first;
        if (ok[t[pos]]) {
          s.insert(pos);
          add(pos, 1);
        }
        ustaw(pos, t[pos] - g[t[pos]]);
      }
    }
  }
  return 0;
}
