#include <bits/stdc++.h>
using namespace std;
const int N = 80;
int f[N][N][N][2], s[N][3];
int kn, vn, xn, pv[N], pk[N], px[N];
char ch[N];
int n;
void upd(int &x, int y) { x = min(x, y); }
int get(int d, int f, int v, int k, int x) {
  int tot = 0, cnt[3];
  cnt[0] = max(s[d][0] - v, 0);
  cnt[1] = max(s[d][1] - k, 0);
  cnt[2] = max(s[d][2] - x, 0);
  for (register int i = (0); i <= (2); ++i)
    if (i != f) tot += cnt[i];
  return tot;
}
signed main() {
  scanf("%d", &n);
  scanf("%s", ch + 1);
  bool flag = 0;
  for (register int i = (1); i <= (n); ++i) {
    s[i][0] = s[i - 1][0];
    s[i][1] = s[i - 1][1];
    s[i][2] = s[i - 1][2];
    if (ch[i] == 'V')
      s[i][0]++, pv[++vn] = i;
    else if (ch[i] == 'K')
      s[i][1]++, pk[++kn] = i;
    else
      s[i][2]++, px[++xn] = i;
    if (ch[i] == 'K' && ch[i - 1] == 'V') flag = 1;
  }
  if (!flag) {
    printf("0\n");
    return 0;
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0][0][0] = 0;
  for (register int v = (0); v <= (vn); ++v)
    for (register int k = (0); k <= (kn); ++k)
      for (register int x = (0); x <= (xn); ++x) {
        if (v < vn)
          upd(f[v + 1][k][x][1],
              min(f[v][k][x][0], f[v][k][x][1]) + get(pv[v + 1], 0, v, k, x));
        if (k < kn)
          upd(f[v][k + 1][x][0], f[v][k][x][0] + get(pk[k + 1], 1, v, k, x));
        if (x < xn)
          upd(f[v][k][x + 1][0],
              min(f[v][k][x][0], f[v][k][x][1]) + get(px[x + 1], 2, v, k, x));
      }
  int ans = min(f[vn][kn][xn][0], f[vn][kn][xn][1]);
  printf("%d\n", ans);
  return 0;
}
