#include <bits/stdc++.h>
using namespace std;
int n;
char s[100];
int dp[80][80][80][2];
int cntv, cntk, cntx;
int get(int v, int k, int x, char req) {
  int ux, uv, uk;
  int unused = 0;
  ux = uv = uk = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'V' && uv < v)
      uv++;
    else if (s[i] == 'K' && uk < k)
      uk++;
    else if (s[i] == 'X' && ux < x)
      ux++;
    else if (s[i] == req)
      return unused;
    else
      ++unused;
  }
  return 0;
}
int main() {
  cin >> n;
  cin >> (s + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'V')
      cntv++;
    else if (s[i] == 'K')
      cntk++;
    else {
      s[i] = 'X';
      cntx++;
    }
  }
  dp[0][0][0][0] = dp[0][0][0][1] = 0;
  for (int v = 0; v <= cntv; v++) {
    for (int k = 0; k <= cntk; k++) {
      for (int x = 0; x <= cntx; x++) {
        if (!v && !k && !x) continue;
        int vswp = v > 0 ? get(v - 1, k, x, 'V') : 1 << 30;
        int kswp = k > 0 ? get(v, k - 1, x, 'K') : 1 << 30;
        int xswp = x > 0 ? get(v, k, x - 1, 'X') : 1 << 30;
        dp[v][k][x][0] = min(min(k > 0 ? dp[v][k - 1][x][0] + kswp : 1 << 30,
                                 x > 0 ? dp[v][k][x - 1][0] + xswp : 1 << 30),
                             x > 0 ? dp[v][k][x - 1][1] + xswp : 1 << 30);
        dp[v][k][x][1] = min(v > 0 ? dp[v - 1][k][x][0] + vswp : 1 << 30,
                             v > 0 ? dp[v - 1][k][x][1] + vswp : 1 << 30);
      }
    }
  }
  cout << min(dp[cntv][cntk][cntx][0], dp[cntv][cntk][cntx][1]) << '\n';
  return 0;
}
