Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya has an array consisting of n numbers. He wants to perform m operations of two types: 

  * add l r d — add an integer d to all elements whose indexes belong to the interval from l to r, inclusive (1 ≤ l ≤ r ≤ n, 1 ≤ d ≤ 104); 
  * count l r — find and print on the screen how many lucky numbers there are among elements with indexes that belong to the interval from l to r inclusive (1 ≤ l ≤ r ≤ n). Each lucky number should be counted as many times as it appears in the interval. 



Petya has a list of all operations. The operations are such that after all additions the array won't have numbers that would exceed 104. Help Petya write a program that would perform these operations.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105) — the number of numbers in the array and the number of operations correspondingly. The second line contains n positive integers, none of which exceeds 104 — those are the array numbers. Next m lines contain operations, one per line. They correspond to the description given in the statement.

It is guaranteed that after all operations are fulfilled each number in the array will not exceed 104.

Output

For each operation of the second type print the single number on the single line — the number of lucky numbers in the corresponding interval.

Examples

Input

3 6
2 3 4
count 1 3
count 1 2
add 1 3 2
count 1 3
add 2 3 3
count 1 3


Output

1
0
1
1


Input

4 5
4 4 4 4
count 1 4
add 1 4 3
count 1 4
add 2 3 40
count 1 4


Output

4
4
4

Note

In the first sample after the first addition the array will look in the following manner:

4 5 6

After the second addition:

4 8 9

The second sample after the first addition:

7 7 7 7

After the second addition:

7 47 47 7
#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans;
int a[1000000];
int tree[1000000];
int b[50] = {
    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,
};
int f[1000000];
void pushup(int id) { tree[id] = tree[id * 2] + tree[id * 2 + 1]; }
void Update(int id, int le, int ri, int x, int k) {
  if (le == ri) {
    tree[id] += k;
    return;
  }
  int mid = (le + ri) / 2;
  if (x <= mid)
    Update(id * 2, le, mid, x, k);
  else
    Update(id * 2 + 1, mid + 1, ri, x, k);
  pushup(id);
}
int query(int id, int le, int ri, int ll, int rr) {
  if (ll <= le && ri <= rr) return tree[id];
  int mid = (le + ri) / 2, k = 0;
  if (ll <= mid) k += query(id * 2, le, mid, ll, rr);
  if (rr > mid) k += query(id * 2 + 1, mid + 1, ri, ll, rr);
  return k;
}
int main() {
  int i, n, m;
  scanf("%d%d", &n, &m);
  memset(f, 0, sizeof(f));
  for (i = 1; i <= 50; i++) f[b[i]] = 1;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (f[a[i]]) Update(1, 1, n, i, 1);
  }
  while (m--) {
    char ch[100];
    scanf("%s", &ch);
    int x, y, z;
    scanf("%d%d", &x, &y);
    if (!strcmp(ch, "add")) {
      scanf("%d", &z);
      for (int i = x; i <= y; i++) {
        int k = 0;
        if (f[a[i]]) k--;
        a[i] += z;
        if (f[a[i]]) k++;
        if (k) Update(1, 1, n, i, k);
      }
    } else
      printf("%d\n", query(1, 1, n, x, y));
  }
  return 0;
}
