#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
const int MAXQ = 20000;
const int MAXALPH = 10;
int n, nq, k;
char s[MAXN + 1];
char p[MAXALPH + 1];
map<int, char> x;
int cnt[MAXALPH][MAXALPH];
void run() {
  scanf("%d%d%d%s", &n, &nq, &k, s);
  x.clear();
  memset(cnt, 0, sizeof(cnt));
  x.insert(make_pair(0, 'x'));
  for (int i = (0); i < (n); ++i) x.insert(make_pair(i + 1, s[i]));
  x.insert(make_pair(n + 1, 'x'));
  for (int i = (1); i < (n); ++i) ++cnt[s[i - 1] - 'a'][s[i] - 'a'];
  for (int qi = (0); qi < (nq); ++qi) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int l, r;
      char c;
      scanf("%d%d %c", &l, &r, &c);
      map<int, char>::iterator i = x.lower_bound(l);
      if (i->first >= l) --i;
      if (i->second != 'x') ++cnt[i->second - 'a'][c - 'a'];
      cnt[c - 'a'][c - 'a'] += r - l;
      map<int, char>::iterator j = i;
      ++j;
      while (true) {
        if (j->first == r + 1) {
          cnt[i->second - 'a'][i->second - 'a'] -= r - max(l - 1, i->first);
          if (j->second != 'x')
            --cnt[i->second - 'a'][j->second - 'a'],
                ++cnt[c - 'a'][j->second - 'a'];
          if (i->first >= l) x.erase(i);
          break;
        } else if (j->first > r + 1) {
          cnt[i->second - 'a'][i->second - 'a'] -= r - max(l - 1, i->first);
          --cnt[i->second - 'a'][i->second - 'a'],
              ++cnt[c - 'a'][i->second - 'a'];
          char cc = i->second;
          if (i->first >= l) x.erase(i);
          x.insert(make_pair(r + 1, cc));
          break;
        } else {
          if (i->second != 'x')
            cnt[i->second - 'a'][i->second - 'a'] -=
                j->first - 1 - max(l - 1, i->first);
          if (i->second != 'x') --cnt[i->second - 'a'][j->second - 'a'];
          if (i->first >= l) x.erase(i);
        }
        i = j++;
      }
      x.insert(make_pair(l, c));
    }
    if (type == 2) {
      scanf("%s", p);
      int ret = 1;
      for (int i = (0); i < (k); ++i)
        for (int j = (0); j <= (i); ++j) ret += cnt[p[i] - 'a'][p[j] - 'a'];
      printf("%d\n", ret);
    }
  }
}
int main() {
  run();
  return 0;
}
