#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;
}
