#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 111;
int dp[N][N][N][2];
vector<int> vpos, kpos, xpos;
string s;
int V, K, X;
int n;
void reset() {
  for (int i = 0; i <= V; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= X; k++) {
        for (int l = 0; l < 2; l++) {
          dp[i][j][k][l] = INF;
        }
      }
    }
  }
}
int cost(int v, int k, int x, int type) {
  int pos;
  if (type == 0)
    pos = vpos[v + 1];
  else if (type == 1)
    pos = kpos[k + 1];
  else
    pos = xpos[x + 1];
  while (v > 0 && vpos[v] > pos) v--;
  while (k > 0 && kpos[k] > pos) k--;
  while (x > 0 && xpos[x] > pos) x--;
  return pos - 1 - (v + k + x);
}
int main() {
  cin >> n >> s;
  vpos.push_back(0);
  kpos.push_back(0);
  xpos.push_back(0);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'V')
      V++, vpos.push_back(i + 1);
    else if (s[i] == 'K')
      K++, kpos.push_back(i + 1);
    else
      X++, xpos.push_back(i + 1);
  }
  reset();
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= V; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= X; k++) {
        for (int l = 0; l < 2; l++) {
          int now = dp[i][j][k][l];
          if (i < V)
            dp[i + 1][j][k][1] =
                min(dp[i + 1][j][k][1], now + cost(i, j, k, 0));
          if (j < K && l == 0)
            dp[i][j + 1][k][0] =
                min(dp[i][j + 1][k][0], now + cost(i, j, k, 1));
          if (k < X)
            dp[i][j][k + 1][0] =
                min(dp[i][j][k + 1][0], now + cost(i, j, k, 2));
        }
      }
    }
  }
  cout << min(dp[V][K][X][0], dp[V][K][X][1]);
  return 0;
}
