#include <bits/stdc++.h>
using namespace std;
int V, K, X;
int tv[100], tk[100], tx[100];
int sv[100], sk[100], sx[100];
int dp[100][100][100][2];
int solve(int t, int i, int j, int k) {
  int res = t - (i + j + k + 1);
  res += max(0, i - sv[t - 1]) + max(0, j - sk[t - 1]) + max(0, k - sx[t - 1]);
  return res;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  s = ' ' + s;
  for (int i = 1; i <= n; i++) {
    sv[i] = sv[i - 1];
    sk[i] = sk[i - 1];
    sx[i] = sx[i - 1];
    if (s[i] == 'V')
      tv[++V] = i, sv[i]++;
    else if (s[i] == 'K')
      tk[++K] = i, sk[i]++;
    else
      tx[++X] = i, sx[i]++;
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= V; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= X; k++) {
        if (i < V)
          dp[i + 1][j][k][1] =
              min(dp[i + 1][j][k][1], min(dp[i][j][k][0], dp[i][j][k][1]) +
                                          solve(tv[i + 1], i, j, k));
        if (j < K)
          dp[i][j + 1][k][0] = min(dp[i][j + 1][k][0],
                                   dp[i][j][k][0] + solve(tk[j + 1], i, j, k));
        if (k < X)
          dp[i][j][k + 1][0] =
              min(dp[i][j][k + 1][0], min(dp[i][j][k][0], dp[i][j][k][1]) +
                                          solve(tx[k + 1], i, j, k));
      }
    }
  }
  cout << min(dp[V][K][X][0], dp[V][K][X][1]) << endl;
  return 0;
}
