#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sum = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  if (f) return -sum;
  return sum;
}
inline int getc() {
  char c = getchar();
  while (c < 'A' || c > 'Z') c = getchar();
  if (c == 'V') return 0;
  if (c == 'K') return 1;
  return 2;
}
const int N = 76;
const int orz = 1000000000;
int n, l0, l1, l2, S0[N], S1[N], S2[N];
int f[N][N][N][3];
inline void up(int &x, int y) {
  if (y < x) x = y;
}
inline int b0(int x, int l) {
  int B = l++, r = l0, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (S0[mid] > x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return r - B;
}
inline int b1(int x, int l) {
  int B = l++, r = l1, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (S1[mid] > x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return r - B;
}
inline int b2(int x, int l) {
  int B = l++, r = l2, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (S2[mid] > x)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return r - B;
}
inline int calc(int tp, int ps, int la, int lb) {
  if (tp == 0) return b1(ps, la) + b2(ps, lb);
  if (tp == 1) return b0(ps, la) + b2(ps, lb);
  return b0(ps, la) + b1(ps, lb);
}
int main() {
  int i, j, k, t, x;
  n = read();
  for (i = 1; i <= n; i++) {
    x = getc();
    if (!x)
      S0[++l0] = i;
    else if (x == 1)
      S1[++l1] = i;
    else
      S2[++l2] = i;
  }
  for (i = 0; i <= l0; i++)
    for (j = 0; j <= l1; j++)
      for (k = 0; k <= l2; k++)
        for (t = 0; t <= 2; t++) f[i][j][k][t] = orz;
  f[0][0][0][2] = 0;
  for (i = 0; i <= l0; i++)
    for (j = 0; j <= l1; j++)
      for (k = 0; k <= l2; k++)
        for (t = 0; t <= 2; t++)
          if (f[i][j][k][t] != orz) {
            x = f[i][j][k][t];
            if (i != l0) up(f[i + 1][j][k][0], x + calc(0, S0[i + 1], j, k));
            if (j != l1 && t)
              up(f[i][j + 1][k][1], x + calc(1, S1[j + 1], i, k));
            if (k != l2) up(f[i][j][k + 1][2], x + calc(2, S2[k + 1], i, j));
          }
  int ans = orz;
  for (t = 0; t <= 2; t++) up(ans, f[l0][l1][l2][t]);
  printf("%d", ans);
  return 0;
}
