#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int maxm = 100010;
int n, m, a[maxn];
int BLOCK_SIZE;
int isLucky[10005];
int luckys[] = {0,    4,    7,    44,   47,   74,   77,   444,
                447,  474,  477,  744,  747,  774,  777,  4444,
                4447, 4474, 4477, 4744, 4747, 4774, 4777, 7444,
                7447, 7474, 7477, 7744, 7747, 7774, 7777, 0};
inline int ceil(int num, int d) {
  return (int)(num / d) + (num % d > 0 ? 1 : 0);
}
inline int block_no(int idx) { return ceil(idx, BLOCK_SIZE); }
inline int block_starting(int idx) {
  return ((block_no(idx) - 1) * BLOCK_SIZE) + 1;
}
inline int block_ending(int idx) {
  return min(n, block_starting(idx) + BLOCK_SIZE - 1);
}
inline int block_ranking(int idx) {
  return idx % BLOCK_SIZE == 0 ? BLOCK_SIZE : idx % BLOCK_SIZE;
}
int block[330][10010], lazy[330];
void update(int left, int right, int val) {
  int lb = block_no(left), rb = block_no(right);
  if (lb == rb) {
    for (int i = left; i <= right; i++) {
      block[lb][a[i]]--;
      a[i] += val;
      block[lb][a[i]]++;
    }
    return;
  }
  for (int i = lb + 1; i <= rb - 1; i++) lazy[i] += val;
  int l_end = block_ending(left), r_start = block_starting(right);
  for (int i = left; i <= l_end; i++) {
    block[lb][a[i]]--;
    a[i] += val;
    block[lb][a[i]]++;
  }
  for (int i = r_start; i <= right; i++) {
    block[rb][a[i]]--;
    a[i] += val;
    block[rb][a[i]]++;
  }
}
int query(int left, int right) {
  int lb = block_no(left), rb = block_no(right);
  if (lb == rb) {
    int ret = 0;
    for (int i = left; i <= right; i++) {
      ret += isLucky[a[i] + lazy[lb]];
    }
    return ret;
  }
  int ret = 0;
  int l_end = block_ending(left), r_start = block_starting(right);
  for (int i = left; i <= l_end; i++) {
    ret += isLucky[a[i] + lazy[lb]];
  }
  for (int i = r_start; i <= right; i++) {
    ret += isLucky[a[i] + lazy[rb]];
  }
  for (int i = lb + 1; i <= rb - 1; i++) {
    for (int j = 1; j <= 30; j++) {
      if (lazy[i] <= luckys[j]) ret += block[i][luckys[j] - lazy[i]];
    }
  }
  return ret;
}
int32_t main() {
  for (int i = 1; i <= 30; i++) isLucky[luckys[i]] = 1;
  scanf("%d", &n);
  scanf("%d", &m);
  BLOCK_SIZE = 2000;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int no = block_no(i);
    block[no][a[i]]++;
  }
  while (m--) {
    string s;
    cin >> s;
    if (s == "add") {
      int l, r, val;
      scanf("%d", &l);
      scanf("%d", &r);
      scanf("%d", &val);
      update(l, r, val);
    } else {
      int l, r;
      scanf("%d", &l);
      scanf("%d", &r);
      printf("%d\n", query(l, r));
    }
  }
  return 0;
}
