#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
void chkmin(int &a, int b) {
  if (b < a) a = b;
}
const int N = 81;
const int INF = 88888888;
int n;
int dp[N][N][N][3];
char s[N];
vector<int> V, K, O;
int calc(int pos, int a, int b, int c) {
  int ret = 0;
  for (int i = 1; i <= pos - 1; i++) {
    if (s[i] == 'V') {
      if (a)
        a--;
      else
        ++ret;
    }
    if (s[i] == 'K') {
      if (b)
        b--;
      else
        ++ret;
    }
    if (s[i] != 'V' && s[i] != 'K') {
      if (c)
        c--;
      else
        ++ret;
    }
  }
  return ret;
}
int main() {
  n = read();
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'V')
      V.push_back(i);
    else if (s[i] == 'K')
      K.push_back(i);
    else
      O.push_back(i);
  }
  for (int a = 0; a <= n; a++)
    for (int b = 0; b <= n; b++)
      for (int c = 0; c <= n; c++)
        for (int d = 0; d <= 1; d++) dp[a][b][c][d] = INF;
  dp[0][0][0][0] = 0;
  for (int a = 0; a <= V.size(); a++) {
    for (int b = 0; b <= K.size(); b++) {
      for (int c = 0; c <= O.size(); c++) {
        for (int flag = 0; flag <= 1; flag++) {
          if (a < V.size())
            chkmin(dp[a + 1][b][c][1], dp[a][b][c][flag] + calc(V[a], a, b, c));
          if (b < K.size() && !flag)
            chkmin(dp[a][b + 1][c][0], dp[a][b][c][flag] + calc(K[b], a, b, c));
          if (c < O.size())
            chkmin(dp[a][b][c + 1][0], dp[a][b][c][flag] + calc(O[c], a, b, c));
        }
      }
    }
  }
  printf("%d\n", min(dp[V.size()][K.size()][O.size()][0],
                     dp[V.size()][K.size()][O.size()][1]));
  return 0;
}
