#include <bits/stdc++.h>
int p[10005], num[105], n, q, sz, sum, cnt = 0, g[100005];
int can(int x) { return x == 4 || x == 7; }
int check(int x, int now) {
  if (!x) return now;
  return can(x % 10) && check(x / 10, 1);
}
struct block {
  int index, l, r, tag, s[20005], f[505];
  int get(int x) { return x - l + 1; }
  void pre(int k, int x, int y) { index = k, l = x, r = y; }
  void in(int x, int val) {
    f[get(x)] = val;
    for (int k = 1; k <= 30; k++) ++s[num[k] - f[get(x)] + 10000];
  }
  int query_all() { return s[tag + 10000]; }
  int query_pre(int x) {
    int ans = 0;
    for (int i = l; i <= x; i++)
      if (p[f[get(i)] + tag]) ++ans;
    return ans;
  }
  int query_suf(int x) {
    int ans = 0;
    for (int i = x; i <= r; i++)
      if (p[f[get(i)] + tag]) ++ans;
    return ans;
  }
  int query_mid(int x, int y) {
    int ans = 0;
    for (int i = x; i <= y; i++)
      if (p[f[get(i)] + tag]) ++ans;
    return ans;
  }
  void add_all(int val) { tag = tag + val; }
  void add_pre(int x, int val) {
    for (int i = l; i <= x; i++) {
      for (int k = 1; k <= 30; k++) --s[num[k] - f[get(i)] + 10000];
      f[get(i)] = f[get(i)] + val;
      for (int k = 1; k <= 30; k++) ++s[num[k] - f[get(i)] + 10000];
    }
  }
  void add_suf(int x, int val) {
    for (int i = x; i <= r; i++) {
      for (int k = 1; k <= 30; k++) --s[num[k] - f[get(i)] + 10000];
      f[get(i)] = f[get(i)] + val;
      for (int k = 1; k <= 30; k++) ++s[num[k] - f[get(i)] + 10000];
    }
  }
  void add_mid(int x, int y, int val) {
    for (int i = x; i <= y; i++) {
      for (int k = 1; k <= 30; k++) --s[num[k] - f[get(i)] + 10000];
      f[get(i)] = f[get(i)] + val;
      for (int k = 1; k <= 30; k++) ++s[num[k] - f[get(i)] + 10000];
    }
  }
};
block a[505];
int main() {
  scanf("%d%d", &n, &q);
  sz = sqrt(n);
  sum = (n - 1) / sz + 1;
  for (int i = 1; i <= 10000; i++)
    if (check(i, 0)) p[num[++cnt] = i] = 1;
  for (int i = 1; i <= sum; i++)
    a[i].pre(i, (i - 1) * sz + 1, std::min(i * sz, n));
  for (int i = 1; i <= n; i++) g[i] = (i - 1) / sz + 1;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[g[i]].in(i, x);
  }
  while (q--) {
    int x, y, v, ans = 0;
    char ch[10];
    scanf("%s", &ch);
    if (std::strlen(ch) == 5) {
      scanf("%d %d", &x, &y);
      for (int i = g[x] + 1; i <= g[y] - 1; i++) ans = ans + a[i].query_all();
      if (g[x] != g[y])
        ans = ans + a[g[x]].query_suf(x) + a[g[y]].query_pre(y);
      else
        ans = ans + a[g[x]].query_mid(x, y);
      printf("%d\n", ans);
    } else if (std::strlen(ch) == 3) {
      scanf("%d %d %d", &x, &y, &v);
      for (int i = g[x] + 1; i <= g[y] - 1; i++) a[i].add_all(v);
      if (g[x] != g[y])
        a[g[x]].add_suf(x, v), a[g[y]].add_pre(y, v);
      else
        a[g[x]].add_mid(x, y, v);
    }
  }
  return 0;
}
