#include <bits/stdc++.h>
using namespace std;
const int maxn = 85;
int f[maxn][maxn][maxn][3], n, a[maxn], c[3], cnt[3];
int _read() {
  char ch = getchar();
  while (ch < 'A' || ch > 'Z') ch = getchar();
  if (ch == 'V') return 1;
  if (ch == 'K') return 2;
  return 0;
}
void updata(int &x, int y) {
  if (y < x) x = y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) a[i] = _read();
  memset(f, 63, sizeof(f));
  for (int i = n; i >= 1; i--) f[a[i] == 1][a[i] == 2][a[i] == 0][a[i]] = i - 1;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++)
        if (i + j + k < n) {
          int tot = 0;
          memset(c, 0, sizeof(c));
          cnt[1] = i, cnt[2] = j, cnt[0] = k;
          for (int d = 1; d <= n; d++)
            if (cnt[a[d]])
              cnt[a[d]]--;
            else {
              tot++;
              if (!c[a[d]]) c[a[d]] = tot;
            }
          for (int l = 0; l < 3; l++) {
            if (f[i][j][k][l] > n * n) continue;
            updata(f[i][j][k + 1][0], f[i][j][k][l] + c[0] - 1);
            updata(f[i + 1][j][k][1], f[i][j][k][l] + c[1] - 1);
            if (l != 1) updata(f[i][j + 1][k][2], f[i][j][k][l] + c[2] - 1);
          }
        }
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= n; i++) c[a[i]]++;
  updata(f[c[1]][c[2]][c[0]][0], f[c[1]][c[2]][c[0]][1]);
  updata(f[c[1]][c[2]][c[0]][0], f[c[1]][c[2]][c[0]][2]);
  printf("%d\n", f[c[1]][c[2]][c[0]][0]);
}
