#include <bits/stdc++.h>
using namespace std;
const int M = 11111;
const int N = 111111;
const int R = 333;
vector<int> lucky;
bool lc[M];
bool test(int x) {
  while (x > 0) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
void PRE() {
  lucky.clear();
  for (int i = 1; i < M; i++)
    if (lc[i] = test(i)) lucky.push_back(i);
}
int cnt[R][M], late[R], rec[N];
int n, m, r;
void update(int L, int R, int d) {
  L--, R--;
  int a = L / r + 1, b = R / r;
  for (int i = a; i < b; i++) late[i] += d;
  if (a == b + 1) {
    for (int i = L; i <= R; i++) {
      cnt[b][rec[i]]--;
      rec[i] += d;
      cnt[b][rec[i]]++;
    }
  } else {
    for (int i = L, t = a * r; i < t; i++) {
      cnt[a - 1][rec[i]]--;
      rec[i] += d;
      cnt[a - 1][rec[i]]++;
    }
    for (int i = b * r; i <= R; i++) {
      cnt[b][rec[i]]--;
      rec[i] += d;
      cnt[b][rec[i]]++;
    }
  }
}
int query(int L, int R) {
  L--, R--;
  int a = L / r + 1, b = R / r, ret = 0;
  vector<int>::iterator vi;
  for (int i = a; i < b; i++) {
    for (vi = lucky.begin(); vi != lucky.end(); vi++) {
      if (*vi - late[i] >= 0) ret += cnt[i][*vi - late[i]];
    }
  }
  if (a == b + 1) {
    for (int i = L; i <= R; i++) {
      if (lc[rec[i] + late[b]]) ret++;
    }
  } else {
    for (int i = L, t = a * r; i < t; i++) {
      if (lc[rec[i] + late[a - 1]]) ret++;
    }
    for (int i = b * r; i <= R; i++) {
      if (lc[rec[i] + late[b]]) ret++;
    }
  }
  return ret;
}
int main() {
  PRE();
  while (~scanf("%d%d", &n, &m)) {
    memset(cnt, 0, sizeof(cnt));
    memset(late, 0, sizeof(late));
    r = (int)sqrt((double)n - 1) + 1;
    for (int i = 0; i < n; i++) {
      scanf("%d", &rec[i]);
      cnt[i / r][rec[i]]++;
    }
    char op[10];
    int L, R, d;
    while (m--) {
      scanf("%s", op);
      if (!strcmp(op, "count")) {
        scanf("%d%d", &L, &R);
        printf("%d\n", query(L, R));
      }
      if (!strcmp(op, "add")) {
        scanf("%d%d%d", &L, &R, &d);
        update(L, R, d);
      }
    }
  }
  return 0;
}
