#include <bits/stdc++.h>
using namespace std;
int n;
char str[80];
int pos[3][80], cnt[3];
int f[80][80][80][5];
int cost(int v, int k, int others, int limit) {
  int ret = 0, a[] = {v, k, others};
  for (int i = 0; i <= 2; i++)
    for (int j = a[i] + 1; j <= cnt[i] && pos[i][j] < limit; j++) ret++;
  return ret;
}
int main() {
  scanf("%d", &n);
  scanf("%s", str);
  memset(pos, 0, sizeof(pos));
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) {
    if (str[i] == 'V')
      ++cnt[0], pos[0][cnt[0]] = i;
    else if (str[i] == 'K')
      ++cnt[1], pos[1][cnt[1]] = i;
    else
      ++cnt[2], pos[2][cnt[2]] = i;
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0][0][0] = 0;
  for (int i = 0; i <= cnt[0]; i++)
    for (int j = 0; j <= cnt[1]; j++)
      for (int k = 0; k <= cnt[2]; k++)
        for (int last = 0; last <= 1; last++) {
          if (i + 1 <= cnt[0])
            f[i + 1][j][k][1] =
                min(f[i + 1][j][k][1],
                    f[i][j][k][last] + cost(i, j, k, pos[0][i + 1]));
          if (last == 0 && j + 1 <= cnt[1])
            f[i][j + 1][k][0] =
                min(f[i][j + 1][k][0],
                    f[i][j][k][last] + cost(i, j, k, pos[1][j + 1]));
          if (k + 1 <= cnt[2])
            f[i][j][k + 1][0] =
                min(f[i][j][k + 1][0],
                    f[i][j][k][last] + cost(i, j, k, pos[2][k + 1]));
        }
  printf("%d\n",
         min(f[cnt[0]][cnt[1]][cnt[2]][0], f[cnt[0]][cnt[1]][cnt[2]][1]));
  return 0;
}
