#include <bits/stdc++.h>
using namespace std;
const int N = 75 + 10, INF = 0x3f3f3f3f;
int n, dp[N][N][N][2], cnt[3], pos[3][N], used[N];
char s[N];
void init() {
  memset(dp, 0x3f, sizeof(dp));
  memset(cnt, 0, sizeof(cnt));
  memset(used, 0, sizeof(used));
  dp[0][0][0][0] = 0;
}
int cal(int bou) {
  int res = 0;
  for (int i = 0; i < 3; i++)
    for (int j = used[i] + 1; j <= cnt[i] && pos[i][j] < bou; j++) res++;
  return res;
}
int main() {
  while (~scanf("%d%s", &n, s)) {
    init();
    for (int i = 0; i < n; i++) {
      if (s[i] == 'V')
        pos[0][++cnt[0]] = i;
      else if (s[i] == 'K')
        pos[1][++cnt[1]] = i;
      else
        pos[2][++cnt[2]] = i;
    }
    int &v = used[0], &k = used[1], &x = used[2];
    for (v = 0; v <= cnt[0]; v++) {
      for (k = 0; k <= cnt[1]; k++)
        for (x = 0; x <= cnt[2]; x++)
          for (int t = 0; t < 2; t++) {
            int cost = dp[v][k][x][t];
            if (cost == INF) continue;
            if (v < cnt[0])
              dp[v + 1][k][x][1] =
                  min(dp[v + 1][k][x][1], cost + cal(pos[0][v + 1]));
            if (k < cnt[1] && t == 0)
              dp[v][k + 1][x][0] =
                  min(dp[v + 1][k][x][0], cost + cal(pos[1][k + 1]));
            if (x < cnt[2])
              dp[v][k][x + 1][0] =
                  min(dp[v][k][x + 1][0], cost + cal(pos[2][x + 1]));
          }
    }
    printf("%d\n",
           min(dp[cnt[0]][cnt[1]][cnt[2]][0], dp[cnt[0]][cnt[1]][cnt[2]][1]));
  }
  return 0;
}
