#include <bits/stdc++.h>
using namespace std;
int n;
char s[100];
int f[80][80][80][2];
int fck[80][80], fcv[80][80];
int fvk[80][80], fvc[80][80];
int fkc[80][80], fkv[80][80];
int cv, ck, cc;
int v[80], kk[80], c[80];
inline int min(int x, int y) { return x < y ? x : y; }
inline int max(int x, int y) { return x > y ? x : y; }
int cost(int limit, int i, int j, int k) {
  int res = 0;
  for (int ii = i + 1; ii <= cv && v[ii] < limit; ii++) res++;
  for (int ii = j + 1; ii <= ck && kk[ii] < limit; ii++) res++;
  for (int ii = k + 1; ii <= cc && c[ii] < limit; ii++) res++;
  return res;
}
int main() {
  cin >> n;
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'V')
      v[++cv] = i;
    else if (s[i] == 'K')
      kk[++ck] = i;
    else
      c[++cc] = i;
  }
  memset(f, 0x7f, sizeof(f));
  f[0][0][0][0] = 0;
  for (int i = 1; i <= cv; i++)
    for (int j = 1; j <= ck; j++) fvk[i][j] = fck[i][j - 1] + (v[i] < kk[j]);
  for (int i = 1; i <= cv; i++)
    for (int j = 1; j <= cc; j++) fvc[i][j] = fvc[i][j - 1] + (v[i] < c[j]);
  for (int i = 1; i <= ck; i++)
    for (int j = 1; j <= cv; j++) fkv[i][j] = fkv[i][j - 1] + (kk[i] < v[j]);
  for (int i = 1; i <= ck; i++)
    for (int j = 1; j <= cc; j++) fkc[i][j] = fkc[i][j - 1] + (kk[i] < c[j]);
  for (int i = 1; i <= cc; i++)
    for (int j = 1; j <= cv; j++) fcv[i][j] = fcv[i][j - 1] + (c[i] < v[j]);
  for (int i = 1; i <= cc; i++)
    for (int j = 1; j <= ck; j++) fck[i][j] = fck[i][j - 1] + (c[i] < kk[j]);
  for (int i = 0; i <= cv; i++)
    for (int j = 0; j <= ck; j++)
      for (int k = 0; k <= cc; k++) {
        if (i) {
          f[i][j][k][1] =
              min(f[i][j][k][1], f[i - 1][j][k][0] + cost(v[i], i - 1, j, k));
          f[i][j][k][1] =
              min(f[i][j][k][1], f[i - 1][j][k][1] + cost(v[i], i - 1, j, k));
        }
        if (j) {
          f[i][j][k][0] =
              min(f[i][j][k][0], f[i][j - 1][k][0] + cost(kk[j], i, j - 1, k));
        }
        if (k) {
          f[i][j][k][0] =
              min(f[i][j][k][0], f[i][j][k - 1][0] + cost(c[k], i, j, k - 1));
          f[i][j][k][0] =
              min(f[i][j][k][0], f[i][j][k - 1][1] + cost(c[k], i, j, k - 1));
        }
      }
  int ans = min(f[cv][ck][cc][0], f[cv][ck][cc][1]);
  printf("%d\n", ans);
  return 0;
}
