#include <bits/stdc++.h>
using namespace std;
const int N = 80;
const int INF = 1e9;
int dp[N][N][N][2];
int pos[3][N];
int c[3] = {'V', 'K', 'X'};
int cf[N][3];
int calc(int v, int k, int x, int t) {
  if (v < 0 || k < 0 || x < 0) return INF;
  if (v == 0 && k == 0 && x == 0) return 0;
  if (dp[v][k][x][t] >= 0) return dp[v][k][x][t];
  int n = v + k + x;
  int tot;
  int v0 = pos[0][v];
  int k0 = pos[1][k];
  int x0 = pos[2][x];
  if (t == 0) {
    int b = calc(v, k - 1, x, 0);
    tot = min(v, cf[k0][0]) + min(k, cf[k0][1]) + min(x, cf[k0][2]);
    b += max(0, k0 - tot);
    int c = min(calc(v, k, x - 1, 0), calc(v, k, x - 1, 1));
    tot = min(v, cf[x0][0]) + min(k, cf[x0][1]) + min(x, cf[x0][2]);
    c += max(0, x0 - tot);
    return dp[v][k][x][t] = min(b, c);
  } else {
    int a = min(calc(v - 1, k, x, 0), calc(v - 1, k, x, 1));
    tot = min(v, cf[v0][0]) + min(k, cf[v0][1]) + min(x, cf[v0][2]);
    a += max(0, v0 - tot);
    return dp[v][k][x][t] = a;
  }
}
int main() {
  memset(dp, -1, sizeof dp);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt[3] = {0};
  for (int i = 0; i < n; i++) {
    if (s[i] != 'K' && s[i] != 'V') s[i] = 'X';
    for (int j = 0; j < 3; j++) {
      if (s[i] == c[j]) {
        cnt[j]++;
        pos[j][cnt[j]] = i + 1;
        cf[i + 1][j] = 1;
      }
      cf[i + 1][j] += cf[i][j];
    }
  }
  cout << min(calc(cnt[0], cnt[1], cnt[2], 0), calc(cnt[0], cnt[1], cnt[2], 1))
       << endl;
}
