#include <bits/stdc++.h>
using namespace std;
const int maxn = 150;
int sumv[maxn], sumk[maxn], T, sumx[maxn], dp[maxn][maxn][maxn][2], V[maxn],
    K[maxn], X[maxn];
char y[maxn], x[maxn];
int main() {
  scanf("%*d");
  dp[0][0][0][0] = 0;
  dp[0][0][0][1] = 0;
  scanf("%s", x);
  int N = strlen(x);
  for (int i = 0; i < N; i++) {
    sumv[i] = sumv[i - 1];
    sumk[i] = sumk[i - 1];
    sumx[i] = sumx[i - 1];
    if (x[i] == 'V') {
      sumv[i] = sumv[i - 1] + 1;
      V[sumv[i]] = i;
    } else if (x[i] == 'K') {
      sumk[i] = sumk[i - 1] + 1;
      K[sumk[i]] = i;
    } else {
      sumx[i] = sumx[i - 1] + 1;
      X[sumx[i]] = i;
    }
  }
  for (int i = 0; i <= sumv[N - 1]; i++) {
    for (int j = 0; j <= sumk[N - 1]; j++) {
      for (int k = 0; k <= sumx[N - 1]; k++) {
        if (i + j + k == 0) {
          dp[i][j][k][0] = dp[i][j][k][1] = 0;
          continue;
        }
        dp[i][j][k][0] = dp[i][j][k][1] = 0x3fffffff;
        if (i)
          dp[i][j][k][1] =
              min(dp[i][j][k][1],
                  min(dp[i - 1][j][k][0], dp[i - 1][j][k][1]) + V[i] -
                      (i - 1 + min(j, sumk[V[i]]) + min(k, sumx[V[i]])));
        if (j)
          dp[i][j][k][0] = min(dp[i][j][k][0], dp[i][j - 1][k][0] + K[j] -
                                                   (j - 1 + min(i, sumv[K[j]]) +
                                                    min(k, sumx[K[j]])));
        if (k)
          dp[i][j][k][0] =
              min(dp[i][j][k][0],
                  min(dp[i][j][k - 1][0], dp[i][j][k - 1][1]) + X[k] -
                      (k - 1 + min(j, sumk[X[k]]) + min(i, sumv[X[k]])));
      }
    }
  }
  printf("%d\n", min(dp[sumv[N - 1]][sumk[N - 1]][sumx[N - 1]][0],
                     dp[sumv[N - 1]][sumk[N - 1]][sumx[N - 1]][1]));
  return 0;
}
