#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const int INF = 1000000;
int cnt[MAXN][3];
int idx[3][MAXN];
int dp[MAXN][MAXN][MAXN][3];
int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int v = 0, k = 0, x = 0;
  for (int i = 0; i < n; i++) {
    cnt[i][0] = v;
    cnt[i][1] = k;
    cnt[i][2] = x;
    if (s[i] == 'V')
      idx[0][++v] = i;
    else if (s[i] == 'K')
      idx[1][++k] = i;
    else
      idx[2][++x] = i;
  }
  for (int i = 0; i <= v; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= x; l++) {
        if (!(i || j || l)) continue;
        if (i != 0) {
          int id = idx[0][i];
          dp[i][j][l][0] = min(dp[i - 1][j][l][2],
                               min(dp[i - 1][j][l][0], dp[i - 1][j][l][1])) +
                           max(0, cnt[id][1] - j) + max(0, cnt[id][2] - l);
        } else
          dp[i][j][l][0] = INF;
        if (j != 0) {
          int id = idx[1][j];
          dp[i][j][l][1] = min(dp[i][j - 1][l][2], dp[i][j - 1][l][1]) +
                           max(0, cnt[id][0] - i) + max(0, cnt[id][2] - l);
        } else
          dp[i][j][l][1] = INF;
        if (l != 0) {
          int id = idx[2][l];
          dp[i][j][l][2] = min(dp[i][j][l - 1][2],
                               min(dp[i][j][l - 1][0], dp[i][j][l - 1][1])) +
                           max(0, cnt[id][0] - i) + max(0, cnt[id][1] - j);
        } else
          dp[i][j][l][2] = INF;
      }
    }
  }
  cout << min(dp[v][k][x][0], min(dp[v][k][x][1], dp[v][k][x][2]));
  return 0;
}
