#include <bits/stdc++.h>
using namespace std;
char p[80];
int D[80][80][80][3];
int A[80], CA, B[80], CB, C[80], CC;
int Calc(int a, int b, int c, int pv) {
  int i, cc = 0;
  for (i = 1; i <= a; i++)
    if (pv < A[i]) cc++;
  for (i = 1; i <= b; i++)
    if (pv < B[i]) cc++;
  for (i = 1; i <= c; i++)
    if (pv < C[i]) cc++;
  return cc;
}
int main() {
  int i, j, k, l, n;
  scanf("%d", &n);
  scanf("%s", p);
  for (i = 0; p[i]; i++) {
    if (p[i] == 'V')
      A[++CA] = i;
    else if (p[i] == 'K')
      B[++CB] = i;
    else
      C[++CC] = i;
  }
  for (i = 0; i <= CA; i++)
    for (j = 0; j <= CB; j++)
      for (k = 0; k <= CC; k++)
        for (l = 0; l < 3; l++) D[i][j][k][l] = 1e9;
  D[0][0][0][2] = 0;
  for (i = 0; i <= CA; i++) {
    for (j = 0; j <= CB; j++) {
      for (k = 0; k <= CC; k++) {
        for (l = 0; l < 3; l++) {
          if (i != CA) {
            D[i + 1][j][k][0] =
                min(D[i + 1][j][k][0], D[i][j][k][l] + Calc(i, j, k, A[i + 1]));
          }
          if (j != CB && l) {
            D[i][j + 1][k][1] =
                min(D[i][j + 1][k][1], D[i][j][k][l] + Calc(i, j, k, B[j + 1]));
          }
          if (k != CC) {
            D[i][j][k + 1][2] =
                min(D[i][j][k + 1][2], D[i][j][k][l] + Calc(i, j, k, C[k + 1]));
          }
        }
      }
    }
  }
  int res = 1e9;
  for (i = 0; i < 3; i++) res = min(res, D[CA][CB][CC][i]);
  printf("%d\n", res);
}
