#include <bits/stdc++.h>
using namespace std;
const int N = 80;
const int inf = 0x3f3f3f3f;
string s;
vector<int> V, K, X;
int dp[N][N][N][2];
int count(int v, int k, int x, int l) {
  int cnt = 0;
  for (int i = v; i < V.size() && V[i] < l; i++) cnt++;
  for (int i = k; i < K.size() && K[i] < l; i++) cnt++;
  for (int i = x; i < X.size() && X[i] < l; i++) cnt++;
  return cnt;
}
int main() {
  int n;
  scanf("%d", &n);
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'V')
      V.push_back(i);
    else if (s[i] == 'K')
      K.push_back(i);
    else
      X.push_back(i);
  }
  memset(dp, inf, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int v = 0; v <= V.size(); v++)
    for (int k = 0; k <= K.size(); k++)
      for (int x = 0; x <= X.size(); x++)
        for (int i = 0; i < 2; i++) {
          if (v < V.size())
            dp[v + 1][k][x][1] =
                min(dp[v + 1][k][x][1], dp[v][k][x][i] + count(v, k, x, V[v]));
          if (k < K.size() && i != 1)
            dp[v][k + 1][x][0] =
                min(dp[v][k + 1][x][0], dp[v][k][x][i] + count(v, k, x, K[k]));
          if (x < X.size())
            dp[v][k][x + 1][0] =
                min(dp[v][k][x + 1][0], dp[v][k][x][i] + count(v, k, x, X[x]));
        }
  int ans = inf;
  ans = min(ans, dp[V.size()][K.size()][X.size()][0]);
  ans = min(ans, dp[V.size()][K.size()][X.size()][1]);
  cout << ans << endl;
  return 0;
}
