#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 77;
int n;
char s[N];
vector<int> v, k, x;
int dp[N][N][N][2];
int count(vector<int> &list, int from, int w) {
  int cnt = 0;
  for (int i = from; i < list.size(); i++) {
    if (list[i] < w) cnt++;
  }
  return cnt;
}
int cost(int vv, int kk, int xx, int w) {
  return count(v, vv, w) + count(k, kk, w) + count(x, xx, w);
}
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'V')
      v.push_back(i);
    else if (s[i] == 'K')
      k.push_back(i);
    else
      x.push_back(i);
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++)
        for (int l = 0; l < 2; l++) dp[i][j][k][l] = 1e9;
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= v.size(); i++) {
    for (int j = 0; j <= k.size(); j++) {
      for (int p = 0; p <= x.size(); p++) {
        for (int c = 0; c < 2; c++) {
          if (i < v.size())
            dp[i + 1][j][p][1] =
                min(dp[i + 1][j][p][1], cost(i, j, p, v[i]) + dp[i][j][p][c]);
          if (c == 0 && j < k.size())
            dp[i][j + 1][p][0] =
                min(dp[i][j + 1][p][0], cost(i, j, p, k[j]) + dp[i][j][p][c]);
          if (p < x.size())
            dp[i][j][p + 1][0] =
                min(dp[i][j][p + 1][0], cost(i, j, p, x[p]) + dp[i][j][p][c]);
        }
      }
    }
  }
  printf("%d\n", min(dp[v.size()][k.size()][x.size()][0],
                     dp[v.size()][k.size()][x.size()][1]));
  return 0;
}
