#include <bits/stdc++.h>
using namespace std;
int vk[80];
int va[80];
int ka[80];
int kv[80];
int av[80];
int ak[80];
int N, TA, TV, TK;
char arr[80];
int dp[80][80][80][2];
int dfs(int v, int k, int a, bool ant) {
  if (v + k + a == N) return 0;
  if (dp[v][k][a][ant] != -1) return dp[v][k][a][ant];
  int ans = 1e9;
  if (v < TV)
    ans =
        min(ans, dfs(v + 1, k, a, 1) + abs(va[v + 1] - a) + abs(vk[v + 1] - k));
  if (k < TK && !ant)
    ans =
        min(ans, dfs(v, k + 1, a, 0) + abs(ka[k + 1] - a) + abs(kv[k + 1] - v));
  if (a < TA)
    ans =
        min(ans, dfs(v, k, a + 1, 0) + abs(ak[a + 1] - k) + abs(av[a + 1] - v));
  return dp[v][k][a][ant] = ans;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> N;
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= N; i++) {
    cin >> arr[i];
    if (arr[i] == 'V') {
      TV++;
      va[TV] = TA;
      vk[TV] = TK;
    } else if (arr[i] == 'K') {
      TK++;
      ka[TK] = TA;
      kv[TK] = TV;
    } else {
      TA++;
      av[TA] = TV;
      ak[TA] = TK;
    }
  }
  cout << dfs(0, 0, 0, 0) / 2 << "\n";
  return 0;
}
