#include <bits/stdc++.h>
int f[80][80][80][2];
int posV[80], posK[80], posX[80];
int cntV[80], cntK[80], cntX[80];
int NewDist(int pos, int nV, int nK, int nX) {
  int newPos;
  newPos = 1;
  newPos += nV > cntV[pos - 1] ? nV : cntV[pos - 1];
  newPos += nK > cntK[pos - 1] ? nK : cntK[pos - 1];
  newPos += nX > cntX[pos - 1] ? nX : cntX[pos - 1];
  return newPos - (nV + nK + nX + 1);
}
int main(int argc, char *argv[]) {
  int n, nV, nK, nX, i, j, k, t;
  char str[80];
  scanf("%d\n%s", &n, str + 1);
  for (i = 1, nV = nK = nX = 0; i <= n; ++i) {
    cntV[i] = cntV[i - 1];
    cntK[i] = cntK[i - 1];
    cntX[i] = cntX[i - 1];
    if (str[i] == 'V')
      ++cntV[posV[++nV] = i];
    else if (str[i] == 'K')
      ++cntK[posK[++nK] = i];
    else
      ++cntX[posX[++nX] = i];
  }
  memset(f, 0x70, sizeof(f));
  f[0][0][0][0] = 0;
  for (i = 0; i <= nV; ++i)
    for (j = 0; j <= nK; ++j)
      for (k = 0; k <= nX; ++k) {
        if (i) {
          t = f[i - 1][j][k][0] + NewDist(posV[i], i - 1, j, k);
          if (t < f[i][j][k][1]) f[i][j][k][1] = t;
          t = f[i - 1][j][k][1] + NewDist(posV[i], i - 1, j, k);
          if (t < f[i][j][k][1]) f[i][j][k][1] = t;
        }
        if (j) {
          t = f[i][j - 1][k][0] + NewDist(posK[j], i, j - 1, k);
          if (t < f[i][j][k][0]) f[i][j][k][0] = t;
        }
        if (k) {
          t = f[i][j][k - 1][0] + NewDist(posX[k], i, j, k - 1);
          if (t < f[i][j][k][0]) f[i][j][k][0] = t;
          t = f[i][j][k - 1][1] + NewDist(posX[k], i, j, k - 1);
          if (t < f[i][j][k][0]) f[i][j][k][0] = t;
        }
      }
  if (f[nV][nK][nX][0] < f[nV][nK][nX][1])
    printf("%d\n", f[nV][nK][nX][0]);
  else
    printf("%d\n", f[nV][nK][nX][1]);
  return 0;
}
