#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 * 1000 + 5;
const int maxt = 10 * 1000 + 5;
const int sq_s = 1500;
int luck[maxt];
vector<int> luckl;
int A[maxn];
struct sqt {
  int *A, *T;
  int shft;
  int lucks;
  int n;
  sqt(int* init, int N) {
    n = N;
    shft = 0;
    lucks = 0;
    T = new int[maxt];
    for (int i = 0; i < maxt; ++i) {
      T[i] = 0;
    }
    A = init;
    for (int i = 0; i < n; ++i) {
      if (luck[A[i]]) {
        ++lucks;
      }
      ++T[A[i]];
    }
  }
  void plus(int l, int r, int d) {
    for (; l <= r; ++l) {
      if (luck[A[l] + shft]) {
        --lucks;
      }
      --T[A[l]];
      A[l] += d;
      if (luck[A[l] + shft]) {
        ++lucks;
      }
      ++T[A[l]];
    }
  }
  void plus(int d) {
    shft += d;
    lucks = 0;
    for (int i = 0; i < (int)(luckl).size(); ++i) {
      if (luckl[i] - shft >= 0) {
        lucks += T[luckl[i] - shft];
      }
    }
  }
  int count() { return lucks; }
  int count(int l, int r) {
    int res = 0;
    for (; l <= r; ++l) {
      if (luck[A[l] + shft]) {
        ++res;
      }
    }
    return res;
  }
};
struct sq_st {
  vector<sqt> T;
  int n;
  sq_st(int* init, int N) {
    n = N;
    for (int i = 0; i < n / sq_s; ++i) {
      T.push_back(sqt(init + i * sq_s, sq_s));
    }
    if (n % sq_s) {
      T.push_back(sqt(init + (n / sq_s) * sq_s, n % sq_s));
    }
  }
  int count(int l, int r) {
    int res = 0;
    int ll = l / sq_s + 1;
    int rr = r / sq_s;
    for (; ll < rr; ++ll) {
      res += T[ll].count();
    }
    if (l / sq_s == r / sq_s) {
      res += T[l / sq_s].count(l % sq_s, r % sq_s);
    } else {
      res += T[l / sq_s].count(l % sq_s, sq_s - 1);
      res += T[r / sq_s].count(0, r % sq_s);
    }
    return res;
  }
  void plus(int l, int r, int d) {
    int ll = l / sq_s + 1;
    int rr = r / sq_s;
    for (; ll < rr; ++ll) {
      T[ll].plus(d);
    }
    if (l / sq_s == r / sq_s) {
      T[l / sq_s].plus(l % sq_s, r % sq_s, d);
    } else {
      T[l / sq_s].plus(l % sq_s, sq_s - 1, d);
      T[r / sq_s].plus(0, r % sq_s, d);
    }
  }
  void getstat() {
    cout << "### DEBUG GETSTAT ###\n";
    for (int i = 0; i < (int)(T).size(); ++i) {
      cout << "# shft = " << T[i].shft << ", count = " << T[i].count() << " | ";
      for (int j = 0; j < T[i].n; ++j) {
        cout << T[i].A[j] << " ";
      }
      cout << "\n";
    }
  }
};
inline bool is_luck(int x) {
  if (!x) {
    return 0;
  }
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) {
      return 0;
    }
    x /= 10;
  }
  return 1;
}
int main() {
  for (int i = 0; i < maxt; ++i) {
    if (is_luck(i)) {
      luck[i] = 1;
      luckl.push_back(i);
    }
  }
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  sq_st T = sq_st(A, n);
  for (int i = 0; i < m; ++i) {
    string s;
    int l, r;
    cin >> s >> l >> r;
    --l, --r;
    if (s[0] == 'a') {
      int d;
      cin >> d;
      T.plus(l, r, d);
    } else {
      cout << T.count(l, r) << "\n";
    }
  }
  return 0;
}
