#include <bits/stdc++.h>
using namespace std;
int n;
char s[80];
int posv[80], posk[80], posa[80], sumv[80], sumk[80], suma[80], cnta, cntv,
    cntk;
int dp[80][80][80][2];
int main() {
  scanf("%d", &n);
  scanf(" %s", s + 1);
  for (int i = 1; i < (n + 1); i++) {
    suma[i] = suma[i - 1];
    sumv[i] = sumv[i - 1];
    sumk[i] = sumk[i - 1];
    if (s[i] == 'V') {
      sumv[i] += 1;
      cntv++;
      posv[cntv] = i;
    } else if (s[i] == 'K') {
      sumk[i] += 1;
      cntk++;
      posk[cntk] = i;
    } else {
      suma[i] += 1;
      cnta++;
      posa[cnta] = i;
    }
  }
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int i = 0; i < (cntv + 1); i++) {
    for (int j = 0; j < (cntk + 1); j++) {
      for (int k = 0; k < (cnta + 1); k++) {
        int pos = i + j + k + 1;
        if (i < cntv) {
          dp[i + 1][j][k][1] =
              min(dp[i + 1][j][k][1], dp[i][j][k][0] +
                                          max(0, sumk[posv[i + 1]] - j) +
                                          max(0, suma[posv[i + 1]] - k));
          dp[i + 1][j][k][1] =
              min(dp[i + 1][j][k][1], dp[i][j][k][1] +
                                          max(0, sumk[posv[i + 1]] - j) +
                                          max(0, suma[posv[i + 1]] - k));
        }
        if (j < cntk)
          dp[i][j + 1][k][0] =
              min(dp[i][j + 1][k][0], dp[i][j][k][0] +
                                          max(0, sumv[posk[j + 1]] - i) +
                                          max(0, suma[posk[j + 1]] - k));
        if (k < cnta) {
          dp[i][j][k + 1][0] =
              min(dp[i][j][k + 1][0], dp[i][j][k][0] +
                                          max(0, sumv[posa[k + 1]] - i) +
                                          max(0, sumk[posa[k + 1]] - j));
          dp[i][j][k + 1][0] =
              min(dp[i][j][k + 1][0], dp[i][j][k][1] +
                                          max(0, sumv[posa[k + 1]] - i) +
                                          max(0, sumk[posa[k + 1]] - j));
        }
      }
    }
  }
  printf("%d\n", min(dp[cntv][cntk][cnta][1], dp[cntv][cntk][cnta][0]));
}
