#include <bits/stdc++.h>
using namespace std;
vector<int> V, K, X;
char s[100];
int n, f[80][80][80][2], cost[100];
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i <= n - 1; i++) {
    if (s[i] == 'V')
      V.push_back(i);
    else if (s[i] == 'K')
      K.push_back(i);
    else
      X.push_back(i);
  }
  int totv = (int)V.size(), totx = (int)X.size(), totk = (int)K.size();
  for (int i = 0; i <= totv; i++)
    for (int j = 0; j <= totk; j++)
      for (int k = 0; k <= totx; k++) f[i][j][k][0] = f[i][j][k][1] = 1 << 28;
  f[0][0][0][1] = 0;
  for (int i = 0; i <= totv; i++)
    for (int j = 0; j <= totk; j++)
      for (int k = 0; k <= totx; k++) {
        int now1 = i, now2 = j, now3 = k;
        cost[0] = 0;
        for (int l = 1; l <= n - 1; l++) {
          cost[l] = cost[l - 1];
          if (now1 < totv && V[now1] < l) ++cost[l], ++now1;
          if (now2 < totk && K[now2] < l) ++cost[l], ++now2;
          if (now3 < totx && X[now3] < l) ++cost[l], ++now3;
        }
        if (i < totv)
          f[i + 1][j][k][0] =
              min(f[i + 1][j][k][0],
                  min(f[i][j][k][0], f[i][j][k][1]) + cost[V[i]]);
        if (j < totk) {
          f[i][j + 1][k][1] =
              min(f[i][j + 1][k][1], f[i][j][k][1] + cost[K[j]]);
        }
        if (k < totx) {
          f[i][j][k + 1][1] =
              min(f[i][j][k + 1][1],
                  min(f[i][j][k][0], f[i][j][k][1]) + cost[X[k]]);
        }
      }
  printf("%d\n", min(f[totv][totk][totx][0], f[totv][totk][totx][1]));
  return 0;
}
