#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3fLL;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
long long add(long long a, long long b, long long m = 1000000007) {
  long long ret = a + b;
  if (ret >= m) ret -= m;
  return ret;
}
long long subtract(long long a, long long b, long long m = 1000000007) {
  long long ret = a - b;
  if (ret < 0) ret += m;
  return ret;
}
long long mult(long long a, long long b, long long m = 1000000007) {
  long long ret = a * b;
  if (ret >= m) ret %= m;
  return ret;
}
long long bigmod(long long a, long long b, long long m = 1000000007) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = mult(ret, a, m);
    b >>= 1;
    a = mult(a, a, m);
  }
  return ret;
}
long long inverse(long long n, long long m = 1000000007) {
  return bigmod(n, 1000000007 - 2, m);
}
vector<int> lucky;
int n, a[100010], lazy[320], cnt[320][10010], lucky_array[10010];
void gen(int x) {
  if (x > 10000) return;
  ;
  lucky.push_back(x);
  lucky_array[x] = 1;
  gen(x * 10 + 4);
  gen(x * 10 + 7);
}
void build(int id) {
  memset(cnt[id], 0, sizeof(cnt[id]));
  int st = id * 320, en = min(n, st + 320);
  for (int i = (st), _i = (en - 1); i <= _i; ++i) {
    a[i] += lazy[id];
    ++cnt[id][a[i]];
  }
  lazy[id] = 0;
}
void update(int x, int y, int z) {
  int id_x = x / 320, id_y = y / 320;
  if (id_x == id_y) {
    for (int i = (x), _i = (y); i <= _i; ++i) {
      a[i] += z;
    }
    build(id_x);
  } else {
    for (int i = (x), _i = (min(n, (id_x + 1) * 320) - 1); i <= _i; ++i) {
      a[i] += z;
    }
    build(id_x);
    for (int i = (id_x + 1), _i = (id_y - 1); i <= _i; ++i) {
      lazy[i] += z;
    }
    for (int i = (id_y * 320), _i = (y); i <= _i; ++i) {
      a[i] += z;
    }
    build(id_y);
  }
}
int query(int x, int y) {
  int id_x = x / 320, id_y = y / 320;
  int ret = 0;
  if (id_x == id_y) {
    build(id_x);
    for (int i = (x), _i = (y); i <= _i; ++i) ret += lucky_array[a[i]];
  } else {
    build(id_x);
    build(id_y);
    for (int i = (x), _i = (min(n, (id_x + 1) * 320) - 1); i <= _i; ++i) {
      if (lucky_array[a[i]]) ++ret;
    }
    for (int i = (id_x + 1), _i = (id_y - 1); i <= _i; ++i) {
      for (auto it : lucky)
        if (it - lazy[i] >= 0) {
          ret += cnt[i][it - lazy[i]];
        }
    }
    for (int i = (id_y * 320), _i = (y); i <= _i; ++i) {
      if (lucky_array[a[i]]) ++ret;
    }
  }
  return ret;
}
char s[10];
int main() {
  gen(4);
  gen(7);
  sort(lucky.begin(), lucky.end());
  ;
  int q, l, r, x;
  while (scanf("%d%d", &n, &q) == 2) {
    for (int i = 0, _i = (n); i < _i; ++i) scanf("%d", &a[i]);
    for (int i = 0, j = 0; i < n; i += 320, ++j) {
      build(j);
    }
    while (q--) {
      scanf("%s", s);
      if (s[0] == 'c') {
        scanf("%d%d", &l, &r);
        --l, --r;
        printf("%d\n", query(l, r));
      } else {
        scanf("%d%d%d", &l, &r, &x);
        --l, --r;
        update(l, r, x);
      }
    }
    memset(lazy, 0, sizeof(lazy));
    memset(cnt, 0, sizeof(cnt));
  }
  return 0;
}
