#include <bits/stdc++.h>
using namespace std;
const int MAXN = 80;
const int INF = 0x3f3f3f3f;
int dp[MAXN][MAXN][MAXN][2];
int VV[MAXN];
int KK[MAXN];
int XX[MAXN];
int sv, sk, sx;
int find(int *data, int l, int r, int d) {
  int cnt = 0;
  for (int i = l; i < r && data[i] < d; i++) {
    cnt++;
  }
  return cnt;
}
int main() {
  memset(dp, 0x3f, sizeof(dp));
  int n;
  char c;
  scanf("%d%*c", &n);
  for (int i = 0; i < n; i++) {
    scanf("%c", &c);
    if (c == 'V')
      VV[sv++] = i;
    else if (c == 'K')
      KK[sk++] = i;
    else
      XX[sx++] = i;
  }
  dp[0][0][0][0] = 0;
  for (int v = 0; v <= sv; v++)
    for (int k = 0; k <= sk; k++)
      for (int x = 0; x <= sx; x++)
        for (int t = 0; t < 2; t++) {
          int aly = dp[v][k][x][t];
          if (v < sv) {
            int cost = find(KK, k, sk, VV[v]);
            cost += find(XX, x, sx, VV[v]);
            dp[v + 1][k][x][1] = min(dp[v + 1][k][x][1], aly + cost);
          }
          if (k < sk && t == 0) {
            int cost = find(VV, v, sv, KK[k]);
            cost += find(XX, x, sx, KK[k]);
            dp[v][k + 1][x][0] = min(dp[v][k + 1][x][0], aly + cost);
          }
          if (x < sx) {
            int cost = find(VV, v, sv, XX[x]);
            cost += find(KK, k, sk, XX[x]);
            dp[v][k][x + 1][0] = min(dp[v][k][x + 1][0], aly + cost);
          }
        }
  int ans = INF;
  ans = min(dp[sv][sk][sx][0], dp[sv][sk][sx][1]);
  printf("%d\n", ans);
  return 0;
}
