#include <bits/stdc++.h>
using namespace std;
vector<int> V, K, X;
int dp[80][80][80][2];
int calc(int v, int k, int x, int index) {
  int ans = 0;
  for (int i = v; i < V.size(); i++) {
    if (V[i] >= index) break;
    ans++;
  }
  for (int i = k; i < K.size(); i++) {
    if (K[i] >= index) break;
    ans++;
  }
  for (int i = x; i < X.size(); i++) {
    if (X[i] >= index) break;
    ans++;
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == 'V')
      V.push_back(i);
    else if (s[i] == 'K')
      K.push_back(i);
    else
      X.push_back(i);
  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 type = 0; type < 2; type++) {
          dp[v][k][x][type] = 1000000000;
        }
  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 type = 0; type < 2; type++) {
          int temp = dp[v][k][x][type];
          if (v + 1 <= V.size())
            dp[v + 1][k][x][1] =
                min(dp[v + 1][k][x][1], temp + calc(v, k, x, V[v]));
          if (k + 1 <= K.size() && type == 0)
            dp[v][k + 1][x][0] =
                min(dp[v][k + 1][x][0], temp + calc(v, k, x, K[k]));
          if (x + 1 <= X.size())
            dp[v][k][x + 1][0] =
                min(dp[v][k][x + 1][0], temp + calc(v, k, x, X[x]));
        }
  cout << min(dp[V.size()][K.size()][X.size()][0],
              dp[V.size()][K.size()][X.size()][1]);
  return 0;
}
