#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int V[maxn], K[maxn], A[maxn], s1, s2, s3;
int dp[maxn][maxn][maxn][2];
char str[maxn];
void up(int &a, int b) {
  if (b == -1) return;
  if (a == -1 || b < a) a = b;
}
int g1(int i, int x) { return lower_bound(V + i, V + 1 + s1, x) - V - i; }
int g2(int i, int x) { return lower_bound(K + i, K + 1 + s2, x) - K - i; }
int g3(int i, int x) { return lower_bound(A + i, A + 1 + s3, x) - A - i; }
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    if (str[i] == 'V')
      V[++s1] = i;
    else if (str[i] == 'K')
      K[++s2] = i;
    else
      A[++s3] = i;
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= s1; i++)
    for (int j = 0; j <= s2; j++)
      for (int k = 0; k <= s3; k++) {
        if (i + j + k == 0) continue;
        for (int l = 0; l <= 1; l++) {
          int cost;
          if (i > 0 && dp[i - 1][j][k][l] != -1) {
            cost = g2(j + 1, V[i]) + g3(k + 1, V[i]);
            up(dp[i][j][k][1], dp[i - 1][j][k][l] + cost);
          }
          if (j > 0 && dp[i][j - 1][k][l] != -1 && l == 0) {
            cost = g1(i + 1, K[j]) + g3(k + 1, K[j]);
            up(dp[i][j][k][0], dp[i][j - 1][k][l] + cost);
          }
          if (k > 0 && dp[i][j][k - 1][l] != -1) {
            cost = g1(i + 1, A[k]) + g2(j + 1, A[k]);
            up(dp[i][j][k][0], dp[i][j][k - 1][l] + cost);
          }
        }
      }
  int ans = -1;
  up(ans, dp[s1][s2][s3][0]);
  up(ans, dp[s1][s2][s3][1]);
  printf("%d\n", ans);
  return 0;
}
