#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int a[N * 10];
int sum[N * 10], ok[N];
int n, m;
void get_table() {
  ok[4] = ok[7] = ok[44] = ok[47] = ok[74] = ok[77] = 1;
  ok[444] = ok[447] = ok[474] = ok[744] = ok[477] = ok[747] = ok[774] =
      ok[777] = 1;
  ok[4444] = ok[4447] = ok[4474] = ok[4744] = ok[7444] = ok[4477] = ok[4747] =
      ok[7447] = ok[4774] = ok[7474] = ok[7744] = ok[4777] = ok[7477] =
          ok[7747] = ok[7774] = ok[7777] = 1;
}
int lowbit(int x) { return x & (-x); }
void update(int i, int val) {
  while (i <= n) {
    sum[i] += val;
    i += lowbit(i);
  }
}
int query(int i) {
  int ans = 0;
  while (i > 0) {
    ans += sum[i];
    i -= lowbit(i);
  }
  return ans;
}
int main() {
  get_table();
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      if (ok[a[i]]) update(i, 1);
    }
    char op[10];
    while (m--) {
      int b, c;
      scanf("%s", op);
      scanf("%d%d", &b, &c);
      if (op[0] == 'a') {
        int val;
        scanf("%d", &val);
        if (val == 0) continue;
        for (int i = b; i <= c; ++i) {
          if (ok[a[i]]) update(i, -1);
          a[i] += val;
          if (ok[a[i]]) update(i, 1);
        }
      } else {
        printf("%d\n", query(c) - query(b - 1));
      }
    }
  }
  return 0;
}
