#include <bits/stdc++.h>
using namespace std;
const int N = 233;
char s[N];
int dp[N][N][N][2], k[N], v[N], x[N], lk, lv, lx, vv[N], kk[N], xx[N];
int main() {
  int ls;
  scanf("%d", &ls);
  scanf("%s", s + 1);
  lk = lv = lx = 0;
  for (int i = 1; i <= ls; ++i) {
    vv[i] = vv[i - 1];
    kk[i] = kk[i - 1];
    xx[i] = xx[i - 1];
    if (s[i] == 'V')
      v[++lv] = i, vv[i]++;
    else if (s[i] == 'K')
      k[++lk] = i, kk[i]++;
    else
      x[++lx] = i, xx[i]++;
  }
  v[lv + 1] = k[lk + 1] = x[lx + 1] = ls + 1;
  for (int iv = 0; iv <= lv; ++iv)
    for (int ik = 0; ik <= lk; ++ik)
      for (int ix = 0; ix <= lx; ++ix)
        dp[iv][ik][ix][0] = dp[iv][ik][ix][1] = 1e9;
  dp[0][0][0][0] = 0;
  for (int iv = 0; iv <= lv; ++iv)
    for (int ik = 0; ik <= lk; ++ik)
      for (int ix = 0; ix <= lx; ++ix) {
        int jpv = 0, jpk = 0, jpx = 0;
        if (v[iv] > k[ik]) jpv += kk[v[iv]] - ik;
        if (v[iv] > x[ix]) jpv += xx[v[iv]] - ix;
        if (k[ik] > v[iv]) jpk += vv[k[ik]] - iv;
        if (k[ik] > x[ix]) jpk += xx[k[ik]] - ix;
        if (x[ix] > v[iv]) jpx += vv[x[ix]] - iv;
        if (x[ix] > k[ik]) jpx += kk[x[ix]] - ik;
        if (iv)
          dp[iv][ik][ix][1] =
              min(dp[iv - 1][ik][ix][1], dp[iv - 1][ik][ix][0]) + jpv;
        if (ik) dp[iv][ik][ix][0] = dp[iv][ik - 1][ix][0] + jpk;
        if (ix)
          dp[iv][ik][ix][0] =
              min(dp[iv][ik][ix][0],
                  min(dp[iv][ik][ix - 1][0], dp[iv][ik][ix - 1][1]) + jpx);
      }
  printf("%d\n", min(dp[lv][lk][lx][0], dp[lv][lk][lx][1]));
  return 0;
}
