#include <bits/stdc++.h>
using namespace std;
const int N = 77;
const int inf = (int)1e9;
int n;
char s[N];
int dp[N][N][N][2];
int pos[3][N];
int sz[3];
int cnt(int cmp, int which, int idx) {
  int ret = 0;
  for (; idx < sz[which]; idx++) {
    if (pos[which][idx] < cmp)
      ret++;
    else
      break;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] == 'V')
      pos[0][sz[0]++] = i;
    else if (s[i] == 'K')
      pos[1][sz[1]++] = i;
    else
      pos[2][sz[2]++] = i;
  }
  for (int i = 0; i <= sz[0]; i++) {
    for (int j = 0; j <= sz[1]; j++) {
      for (int k = 0; k <= sz[2]; k++) {
        for (int lastv : {0, 1}) {
          if (!i && !j && !k && !lastv) continue;
          dp[i][j][k][lastv] = inf;
          if (i && lastv) {
            dp[i][j][k][lastv] =
                min(dp[i][j][k][lastv],
                    min(dp[i - 1][j][k][0], dp[i - 1][j][k][1]) +
                        cnt(pos[0][i - 1], 1, j) + cnt(pos[0][i - 1], 2, k));
          }
          if (j && !lastv) {
            dp[i][j][k][lastv] =
                min(dp[i][j][k][lastv], dp[i][j - 1][k][0] +
                                            cnt(pos[1][j - 1], 0, i) +
                                            cnt(pos[1][j - 1], 2, k));
          }
          if (k && !lastv) {
            dp[i][j][k][lastv] =
                min(dp[i][j][k][lastv],
                    min(dp[i][j][k - 1][0], dp[i][j][k - 1][1]) +
                        cnt(pos[2][k - 1], 0, i) + cnt(pos[2][k - 1], 1, j));
          }
        }
      }
    }
  }
  int ans = min(dp[sz[0]][sz[1]][sz[2]][0], dp[sz[0]][sz[1]][sz[2]][1]);
  printf("%d\n", ans);
  return 0;
}
