#include <bits/stdc++.h>
using namespace std;
const int N = 80;
int f[N][N][N][3];
char ch[N];
int pos[3][N], s[3];
int cnt[N][3];
int n;
int get(char c) {
  if (c == 'V') return 0;
  if (c == 'K') return 1;
  return 2;
}
void init() {
  for (int i = 1; i <= n; i++) {
    int t = get(ch[i]);
    cnt[i][0] = s[0];
    cnt[i][1] = s[1];
    cnt[i][2] = s[2];
    pos[t][++s[t]] = i;
  }
}
int cost(int t, int a, int b, int c) {
  if (t == 0) {
    int p = pos[t][a];
    int b1 = cnt[p][1];
    int c1 = cnt[p][2];
    return abs(b1 - b) + abs(c1 - c);
  }
  if (t == 1) {
    int p = pos[t][b];
    int a1 = cnt[p][0], c1 = cnt[p][2];
    return abs(a1 - a) + abs(c1 - c);
  } else {
    int p = pos[t][c];
    int a1 = cnt[p][0], b1 = cnt[p][1];
    return abs(a1 - a) + abs(b1 - b);
  }
}
void calc_min(int &a, int b) { a = min(a, b); }
int main() {
  scanf("%d", &n);
  scanf("%s", ch + 1);
  init();
  memset(f, 0x3f, sizeof f);
  f[0][0][0][1] = f[0][0][0][2] = 0;
  for (int i = 0; i <= n; i++)
    for (int a = 0; a <= min(s[0], i); a++)
      for (int b = 0; b <= s[1] && a + b <= i; b++)
        for (int t = 0; t <= 2; t++) {
          int c = i - a - b;
          if (c > s[2]) continue;
          if (a < s[0])
            calc_min(f[i + 1][a + 1][b][0],
                     f[i][a][b][t] + cost(0, a + 1, b, c));
          if (b < s[1] && t)
            calc_min(f[i + 1][a][b + 1][1],
                     f[i][a][b][t] + cost(1, a, b + 1, c));
          if (c < s[2])
            calc_min(f[i + 1][a][b][2], f[i][a][b][t] + cost(2, a, b, c + 1));
        }
  printf("%d\n", min(f[n][s[0]][s[1]][0],
                     min(f[n][s[0]][s[1]][1], f[n][s[0]][s[1]][2])) /
                     2);
  return 0;
}
