#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007ll;
char str[100];
int dp[100][100][100][2];
int len, cntv, cntk, cntx;
int vpos[100];
int kpos[100];
int xpos[100];
int cnt[100][3];
int func(int pos, int v, int k, int f) {
  if (len == pos) {
    if (cntv == v && k == cntk) return 0;
    return 100000000;
  }
  int& res = dp[pos][v][k][f];
  if (res != -1) return res;
  res = 100000000;
  int x = pos - v - k;
  if (cntx > x)
    res = min(res, func(pos + 1, v, k, 0) + abs(cnt[xpos[x]][0] - v) +
                       abs(cnt[xpos[x]][1] - k) + abs(cnt[xpos[x]][2] - x - 1));
  if (cntv > v)
    res = min(res, func(pos + 1, v + 1, k, 1) + abs(cnt[vpos[v]][0] - v - 1) +
                       abs(cnt[vpos[v]][1] - k) + abs(cnt[vpos[v]][2] - x));
  if (cntk > k && f == 0)
    res = min(res, func(pos + 1, v, k + 1, 0) + abs(cnt[kpos[k]][0] - v) +
                       abs(cnt[kpos[k]][1] - k - 1) + abs(cnt[kpos[k]][2] - x));
  return res;
}
int main() {
  scanf("%d", &len);
  scanf("%s", str);
  for (int i = 0; i < len; i++) {
    if (str[i] == 'V') {
      vpos[cntv++] = i;
      cnt[i][0] = 1;
    } else if (str[i] == 'K') {
      kpos[cntk++] = i;
      cnt[i][1] = 1;
    } else {
      xpos[cntx++] = i;
      cnt[i][2] = 1;
    }
  }
  xpos[cntx] = len;
  vpos[cntv] = len;
  kpos[cntk] = len;
  for (int i = 1; i <= len; i++) {
    for (int j = 0; j < 3; j++) {
      cnt[i][j] += cnt[i - 1][j];
    }
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", func(0, 0, 0, 0) / 2);
  return 0;
}
