#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
inline char readch() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n') ch = getchar();
  return ch;
}
inline string readstr() {
  char ch = getchar();
  string ans = "";
  while (ch == ' ' || ch == '\n') ch = getchar();
  while (ch != ' ' && ch != '\n') {
    ans += ch;
    ch = getchar();
  }
  return ans;
}
const int MAXN = 100;
int n;
vector<int> V = {0}, K = {0}, X = {0};
int dp[MAXN][MAXN][MAXN][3];
inline int calc(int x, int y, int z, int pos) {
  int ans = pos - (x + y + z + 1);
  for (int i = 1; i <= x; i++)
    if (V[i] >= pos) ans++;
  for (int i = 1; i <= y; i++)
    if (K[i] >= pos) ans++;
  for (int i = 1; i <= z; i++)
    if (X[i] >= pos) ans++;
  return ans;
}
signed main() {
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  n = read();
  for (int i = 1; i <= n; i++) {
    char tmp = readch();
    if (tmp == 'V')
      V.push_back(i);
    else if (tmp == 'K')
      K.push_back(i);
    else
      X.push_back(i);
  }
  dp[0][0][0][0] = dp[0][0][0][1] = 0;
  for (int i = 0; i < V.size(); i++) {
    for (int j = 0; j < K.size(); j++) {
      for (int k = 0; k < X.size(); k++) {
        if (i != 0)
          dp[i][j][k][1] =
              min(dp[i][j][k][1], min(dp[i - 1][j][k][0], dp[i - 1][j][k][1]) +
                                      calc(i - 1, j, k, V[i]));
        if (k != 0)
          dp[i][j][k][0] =
              min(dp[i][j][k][0], min(dp[i][j][k - 1][0], dp[i][j][k - 1][1]) +
                                      calc(i, j, k - 1, X[k]));
        if (j != 0)
          dp[i][j][k][0] =
              min(dp[i][j][k][0], dp[i][j - 1][k][0] + calc(i, j - 1, k, K[j]));
      }
    }
  }
  cout << min(dp[V.size() - 1][K.size() - 1][X.size() - 1][0],
              dp[V.size() - 1][K.size() - 1][X.size() - 1][1])
       << endl;
  return 0;
}
