Problem: You are given a string s of length n, consisting of first k lowercase English letters.

We define a c-repeat of some string q as a string, consisting of c copies of the string q. For example, string "acbacbacbacb" is a 4-repeat of the string "acb".

Let's say that string a contains string b as a subsequence, if string b can be obtained from a by erasing some symbols.

Let p be a string that represents some permutation of the first k lowercase English letters. We define function d(p) as the smallest integer such that a d(p)-repeat of the string p contains string s as a subsequence.

There are m operations of one of two types that can be applied to string s:

  1. Replace all characters at positions from li to ri by a character ci. 
  2. For the given p, that is a permutation of first k lowercase English letters, find the value of function d(p). 



All operations are performed sequentially, in the order they appear in the input. Your task is to determine the values of function d(p) for all operations of the second type.

Input

The first line contains three positive integers n, m and k (1 ≤ n ≤ 200 000, 1 ≤ m ≤ 20000, 1 ≤ k ≤ 10) — the length of the string s, the number of operations and the size of the alphabet respectively. The second line contains the string s itself.

Each of the following lines m contains a description of some operation: 

  1. Operation of the first type starts with 1 followed by a triple li, ri and ci, that denotes replacement of all characters at positions from li to ri by character ci (1 ≤ li ≤ ri ≤ n, ci is one of the first k lowercase English letters). 
  2. Operation of the second type starts with 2 followed by a permutation of the first k lowercase English letters.

Output

For each query of the second type the value of function d(p).

Examples

Input

7 4 3
abacaba
1 3 5 b
2 abc
1 4 4 c
2 cba


Output

6
5

Note

After the first operation the string s will be abbbbba.

In the second operation the answer is 6-repeat of abc: ABcaBcaBcaBcaBcAbc.

After the third operation the string s will be abbcbba.

In the fourth operation the answer is 5-repeat of cba: cbAcBacBaCBacBA.

Uppercase letters means the occurrences of symbols from the string s.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T min(T a, T b, T c, T d) {
  return min(min(a, b), min(c, d));
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
const int INF = 1e9;
const long long INF_LL = 4e18;
const double pi = acos(-1.0);
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
map<int, int> mp;
int cnt[11 * 11], n, m, k;
char s[200002], t[200002 << 1];
int debug = 0;
void pushDown(int l, int r) {
  int h = (sizeof(int) * 8 - __builtin_clz(n));
  for (l += n, r += n - 1; h > 0; h--) {
    for (int i = (l >> h); i <= (r >> h); i++)
      if (t[i]) {
        t[i << 1] = t[i];
        t[i << 1 | 1] = t[i];
        t[i] = 0;
      }
  }
}
void modify(int l, int r, char c) {
  int l0 = l, r0 = r;
  pushDown(l0, l0 + 1);
  pushDown(r0 - 1, r0);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) t[l++] = c;
    if (r & 1) t[--r] = c;
  }
}
char query(int l, int r) {
  pushDown(l, l + 1);
  pushDown(r - 1, r);
  return t[l + n];
}
int genId(char a, char b) { return (a - 'a' + 1) * 11 + (b - 'a' + 1); }
void modify_cnt(int id, int v) {
  if (debug) {
    char a = id / 11 + 'a' - 1;
    char b = id % 11 + 'a' - 1;
    printf("modify cnt: id=%d(%c%c) v=%d current_v:%d\n", id, a, b, v,
           cnt[id] + v);
  }
  cnt[id] += v;
}
void init() {
  for (int i = 0; i < n; i++) modify(i, i + 1, s[i]);
  for (int i = 1; i < n; i++) {
    int id = genId(s[i - 1], s[i]);
    mp[i] = id;
    modify_cnt(id, 1);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  scanf("%s", s);
  init();
  for (int q = 0; q < m; q++) {
    int op, l, r;
    char c[11], x;
    if (debug) {
      for (int i = 0; i < n; i++) printf("%c", query(i, i + 1));
      puts("");
    }
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%s", &l, &r, c);
      auto itl = mp.lower_bound(l - 1);
      auto itr = mp.upper_bound(r);
      for (auto i = itl; i != itr; i++) modify_cnt(i->second, -1);
      mp.erase(itl, itr);
      if (l > 1) {
        x = query(l - 2, l - 1);
        mp[l - 1] = genId(x, c[0]);
        modify_cnt(genId(x, c[0]), 1);
      }
      if (r < n) {
        x = query(r, r + 1);
        mp[r] = genId(c[0], x);
        modify_cnt(genId(c[0], x), 1);
      }
      modify(l - 1, r, c[0]);
    } else {
      scanf("%s", c);
      int ans = n;
      for (int i = 1; c[i]; i++) {
        for (int j = 0; j < i; j++) {
          modify_cnt(genId(c[j], c[i]), 0);
          ans -= cnt[genId(c[j], c[i])];
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}