#include <bits/stdc++.h>
using namespace std;
inline void Rd(int &res) {
  char c;
  res = 0;
  while (c = getchar(), c < '0')
    ;
  do {
    res = (res << 1) + (res << 3) + (c ^ 48);
  } while (c = getchar(), c >= '0');
}
const int M = 80;
int n;
int cnt[3][M], pos[3][M];
int dp[M][M][M][2];
char str[M];
inline int cost(int v, int k, int x, int pos) {
  return max(0, cnt[0][pos] - v) + max(0, cnt[1][pos] - k) +
         max(0, cnt[2][pos] - x) - 1;
}
inline void Check(int &a, int b) {
  if (a == -1 || b < a) a = b;
}
int main() {
  scanf("%d", &n);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    cnt[0][i] = cnt[0][i - 1] + (str[i] == 'V');
    cnt[1][i] = cnt[1][i - 1] + (str[i] == 'K');
    cnt[2][i] = cnt[2][i - 1] + (str[i] != 'V' && str[i] != 'K');
    if (str[i] == 'V') pos[0][++pos[0][0]] = i;
    if (str[i] == 'K') pos[1][++pos[1][0]] = i;
    if (str[i] != 'V' && str[i] != 'K') pos[2][++pos[2][0]] = i;
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= cnt[0][n]; i++)
    for (int j = 0; j <= cnt[1][n]; j++)
      for (int t = 0; t <= cnt[2][n]; t++)
        for (int p = 0; p < 2; p++) {
          if (dp[i][j][t][p] == -1) continue;
          if (i < cnt[0][n])
            Check(dp[i + 1][j][t][1],
                  dp[i][j][t][p] + cost(i, j, t, pos[0][i + 1]));
          if (!p && j < cnt[1][n])
            Check(dp[i][j + 1][t][0],
                  dp[i][j][t][p] + cost(i, j, t, pos[1][j + 1]));
          if (t < cnt[2][n])
            Check(dp[i][j][t + 1][0],
                  dp[i][j][t][p] + cost(i, j, t, pos[2][t + 1]));
        }
  int rs = -1;
  if (~dp[cnt[0][n]][cnt[1][n]][cnt[2][n]][0])
    Check(rs, dp[cnt[0][n]][cnt[1][n]][cnt[2][n]][0]);
  if (~dp[cnt[0][n]][cnt[1][n]][cnt[2][n]][1])
    Check(rs, dp[cnt[0][n]][cnt[1][n]][cnt[2][n]][1]);
  printf("%d\n", rs);
  return 0;
}
