#include <bits/stdc++.h>
using namespace std;
int V[80], sv;
int K[80], sk;
int A[80], sa;
int dp[80][80][80][2];
char str[80];
int g1(int i, int x) { return lower_bound(V + i, V + 1 + sv, x) - V - i; }
int g2(int i, int x) { return lower_bound(K + i, K + 1 + sk, x) - K - i; }
int g3(int i, int x) { return lower_bound(A + i, A + 1 + sa, 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[++sv] = i;
    else if (str[i] == 'K')
      K[++sk] = i;
    else
      A[++sa] = i;
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= sv; i++) {
    for (int j = 0; j <= sk; j++) {
      for (int k = 0; k <= sa; k++) {
        if (i + j + k == 0) continue;
        for (int l = 0; l < 2; l++) {
          int cost;
          if (i > 0 && dp[i - 1][j][k][l] != -1) {
            cost = g2(j + 1, V[i]) + g3(k + 1, V[i]);
            if (dp[i][j][k][1] == -1 ||
                dp[i][j][k][1] > dp[i - 1][j][k][l] + cost)
              dp[i][j][k][1] = dp[i - 1][j][k][l] + cost;
          }
          if (j > 0 && dp[i][j - 1][k][l] != -1 && l != 1) {
            cost = g1(i + 1, K[j]) + g3(k + 1, K[j]);
            if (dp[i][j][k][0] == -1 ||
                dp[i][j][k][0] > dp[i][j - 1][k][l] + cost)
              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]);
            if (dp[i][j][k][0] == -1 ||
                dp[i][j][k][0] > dp[i][j][k - 1][l] + cost)
              dp[i][j][k][0] = dp[i][j][k - 1][l] + cost;
          }
        }
      }
    }
  }
  int ans = n * 10000;
  if (dp[sv][sk][sa][0] != -1) ans = min(ans, dp[sv][sk][sa][0]);
  if (dp[sv][sk][sa][1] != -1) ans = min(ans, dp[sv][sk][sa][1]);
  printf("%d\n", ans);
  return 0;
}
