#include <bits/stdc++.h>
using namespace std;
const int maxn = 77;
const int INF = 1e9;
int n;
char str[maxn];
int dp[maxn][maxn][maxn][2];
int cv[maxn];
int ck[maxn];
int cx[maxn];
int vp[maxn];
int kp[maxn];
int xp[maxn];
bool ban[maxn];
void ckMin(int &a, int b) {
  if (b < a) {
    a = b;
  }
}
int main() {
  cin >> n;
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    if (str[i] == 'V') {
      cv[i] = cv[i - 1] + 1;
      ck[i] = ck[i - 1];
      cx[i] = cx[i - 1];
      vp[cv[i]] = i;
    } else if (str[i] == 'K') {
      cv[i] = cv[i - 1];
      ck[i] = ck[i - 1] + 1;
      cx[i] = cx[i - 1];
      kp[ck[i]] = i;
    } else {
      cv[i] = cv[i - 1];
      ck[i] = ck[i - 1];
      cx[i] = cx[i - 1] + 1;
      xp[cx[i]] = i;
    }
  }
  for (int i = 0; i < maxn; i++) {
    for (int j = 0; j < maxn; j++) {
      for (int k = 0; k < maxn; k++) {
        dp[i][j][k][0] = dp[i][j][k][1] = INF;
      }
    }
  }
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= cv[n]; i++) {
    for (int j = 0; j <= ck[n]; j++) {
      for (int k = 0; k <= cx[n]; k++) {
        int pos = i + j + k;
        int dis;
        if (i < cv[n]) {
          dis = 0;
          dis += max(0, ck[vp[i + 1]] - j);
          dis += max(0, cx[vp[i + 1]] - k);
          ckMin(dp[i + 1][j][k][1], dp[i][j][k][0] + dis);
          ckMin(dp[i + 1][j][k][1], dp[i][j][k][1] + dis);
        }
        if (j < ck[n]) {
          dis = 0;
          dis += max(0, cv[kp[j + 1]] - i);
          dis += max(0, cx[kp[j + 1]] - k);
          ckMin(dp[i][j + 1][k][0], dp[i][j][k][0] + dis);
        }
        if (k < cx[n]) {
          dis = 0;
          dis += max(0, cv[xp[k + 1]] - i);
          dis += max(0, ck[xp[k + 1]] - j);
          ckMin(dp[i][j][k + 1][0], dp[i][j][k][0] + dis);
          ckMin(dp[i][j][k + 1][0], dp[i][j][k][1] + dis);
        }
      }
    }
  }
  cout << min(dp[cv[n]][ck[n]][cx[n]][0], dp[cv[n]][ck[n]][cx[n]][1]) << endl;
  return 0;
}
