#include <bits/stdc++.h>
using namespace std;
const int maxn = 80;
int dp[maxn][maxn][maxn][3];
char str[maxn];
int n;
int arr[maxn], cnt[3];
int bef[3][maxn][3];
int main() {
  scanf("%d%s", &n, str);
  for (int i = 0; i < n; i++) {
    if (str[i] == 'V')
      arr[i] = 0;
    else if (str[i] == 'K')
      arr[i] = 1;
    else
      arr[i] = 2;
    for (int j = 0; j < 3; j++) bef[arr[i]][cnt[arr[i]]][j] = cnt[j];
    cnt[arr[i]]++;
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0][2] = 0;
  for (int i = 0; i < n; i++) {
    for (int s0 = 0; s0 <= min(i, cnt[0]); s0++)
      for (int s1 = 0; s0 + s1 <= i && s1 <= cnt[1]; s1++)
        for (int last = 0; last < 3; last++) {
          int s2 = i - s0 - s1;
          if (s0 < cnt[0]) {
            int sbef = max(0, bef[0][s0][1] - s1) + max(0, bef[0][s0][2] - s2);
            dp[i + 1][s0 + 1][s1][0] =
                min(dp[i + 1][s0 + 1][s1][0], dp[i][s0][s1][last] + sbef);
          }
          if (s1 < cnt[1] && last != 0) {
            int sbef = max(0, bef[1][s1][0] - s0) + max(0, bef[1][s1][2] - s2);
            dp[i + 1][s0][s1 + 1][1] =
                min(dp[i + 1][s0][s1 + 1][1], dp[i][s0][s1][last] + sbef);
          }
          if (s2 < cnt[2]) {
            int sbef = max(0, bef[2][s2][0] - s0) + max(0, bef[2][s2][1] - s1);
            dp[i + 1][s0][s1][2] =
                min(dp[i + 1][s0][s1][2], dp[i][s0][s1][last] + sbef);
          }
        }
  }
  int ans = 1000000000;
  for (int i = 0; i < 3; i++) ans = min(dp[n][cnt[0]][cnt[1]][i], ans);
  cout << ans << endl;
  return 0;
}
