#include <bits/stdc++.h>
int n, p[110][3], c[110][3], f[110][110][110][2], V, K, X;
char s[110];
int min(int a, int b) { return a < b ? a : b; }
int r(int o, int v, int k, int x) {
  return o - min(c[o][0], v) - min(c[o][1], k) - min(c[o][2], x);
}
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) c[i][j] = c[i - 1][j];
    if (s[i] == 'V')
      V++, p[V][0] = i, c[i][0]++;
    else if (s[i] == 'K')
      K++, p[K][1] = i, c[i][1]++;
    else
      X++, p[X][2] = i, c[i][2]++;
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0][0][0] = 0;
  for (int i = 0; i <= V; i++)
    for (int j = 0; j <= K; j++)
      for (int k = 0; k <= X; k++) {
        int Q = min(f[i][j][k][0], f[i][j][k][1]);
        f[i + 1][j][k][1] =
            min(f[i + 1][j][k][1], Q + r(p[i + 1][0], i + 1, j, k));
        f[i][j + 1][k][0] =
            min(f[i][j + 1][k][0], f[i][j][k][0] + r(p[j + 1][1], i, j + 1, k));
        f[i][j][k + 1][0] =
            min(f[i][j][k + 1][0], Q + r(p[k + 1][2], i, j, k + 1));
      }
  printf("%d", min(f[V][K][X][0], f[V][K][X][1]));
  return 0;
}
