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;
const int N = 200200;
struct node {
  int l, r, son[2];
  int s[10][10];
  char c;
  bool lazy;
} t[N * 2];
int n, m, k, tot, root = 1;
char s[N];
void up(int x) {
  if (t[x].l == t[x].r) return;
  int l = t[x].son[0], r = t[x].son[1];
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) t[x].s[i][j] = t[l].s[i][j] + t[r].s[i][j];
}
void down(int x) {
  if (t[x].l == t[x].r) return;
  if (t[x].lazy) {
    int l = t[x].son[0], r = t[x].son[1];
    for (int i = 0; i < k; i++)
      for (int j = 0; j < k; j++) t[l].s[i][j] = t[r].s[i][j] = 0;
    t[l].c = t[r].c = t[x].c;
    t[l].lazy = t[r].lazy = true;
    t[x].lazy = false;
  }
}
void build(int l, int r) {
  tot++;
  t[tot].l = l;
  t[tot].r = r;
  if (l == r) {
    if (l > 1) t[tot].s[s[l - 1] - 'a'][s[l] - 'a'] = 1;
    t[tot].c = s[l];
    return;
  }
  int now = tot, mid = (l + r) >> 1;
  t[now].son[0] = tot + 1;
  build(l, mid);
  t[now].son[1] = tot + 1;
  build(mid + 1, r);
  up(now);
}
void re(int now, int l, int r, char c) {
  if (t[now].l >= l && t[now].r <= r) {
    for (int i = 0; i < k; i++)
      for (int j = 0; j < k; j++) t[now].s[i][j] = 0;
    t[now].c = c;
    t[now].lazy = true;
    return;
  }
  down(now);
  int mid = (t[now].l + t[now].r) >> 1;
  if (l <= mid) re(t[now].son[0], l, r, c);
  if (mid < r) re(t[now].son[1], l, r, c);
  up(now);
}
void add(int now, int x, char c) {
  if (t[now].l == t[now].r) {
    for (int i = 0; i < k; i++)
      for (int j = 0; j < k; j++) t[now].s[i][j] = 0;
    if (c != t[now].c) t[now].s[c - 'a'][t[now].c - 'a'] = 1;
    return;
  }
  down(now);
  int mid = (t[now].l + t[now].r) >> 1;
  if (x <= mid)
    add(t[now].son[0], x, c);
  else
    add(t[now].son[1], x, c);
  up(now);
}
char get(int now, int x) {
  if (t[now].l == t[now].r) return t[now].c;
  down(now);
  int mid = (t[now].l + t[now].r) >> 1;
  char tmp;
  if (x <= mid)
    tmp = get(t[now].son[0], x);
  else
    tmp = get(t[now].son[1], x);
  up(now);
  return tmp;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  scanf("%s", s + 1);
  build(1, n);
  for (int i = 1; i <= m; i++) {
    int kk;
    scanf("%d", &kk);
    if (kk == 1) {
      int l, r;
      char c;
      scanf("%d%d %c", &l, &r, &c);
      re(root, l, r, c);
      if (l > 1) add(root, l, get(root, l - 1));
      if (r < n) add(root, r + 1, c);
    } else {
      scanf("%s", s + 1);
      int ans = 0;
      for (int j = 1; j < k; j++)
        for (int l = j + 1; l <= k; l++)
          ans += t[root].s[s[j] - 'a'][s[l] - 'a'];
      printf("%d\n", n - ans);
    }
  }
  return 0;
}