#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int inf = 0x3f3f3f3f;
int n;
vector<int> a, b, c;
int cnt[N][3], dp[N][N][N][2];
char s[N];
int main() {
  memset(dp, inf, sizeof(dp));
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    cnt[i][0] = cnt[i - 1][0] + (s[i] == 'V');
    cnt[i][1] = cnt[i - 1][1] + (s[i] == 'K');
    cnt[i][2] = cnt[i - 1][2] + ((s[i] != 'V') && (s[i] != 'K'));
    if (s[i] == 'V')
      a.push_back(i);
    else if (s[i] == 'K')
      b.push_back(i);
    else
      c.push_back(i);
  }
  dp[0][0][0][1] = 0;
  for (int i = 0; i <= a.size(); i++) {
    for (int j = 0; j <= b.size(); j++) {
      for (int k = 0; k <= c.size(); k++) {
        for (int t = 0; t < 2; t++)
          if (dp[i][j][k][t] != inf) {
            if (i < a.size())
              dp[i + 1][j][k][0] =
                  min(dp[i + 1][j][k][0], dp[i][j][k][t] +
                                              max(0, cnt[a[i] - 1][0] - i) +
                                              max(0, cnt[a[i] - 1][1] - j) +
                                              max(0, cnt[a[i] - 1][2] - k));
            if ((j < b.size()) && t)
              dp[i][j + 1][k][1] =
                  min(dp[i][j + 1][k][1], dp[i][j][k][t] +
                                              max(0, cnt[b[j] - 1][0] - i) +
                                              max(0, cnt[b[j] - 1][1] - j) +
                                              max(0, cnt[b[j] - 1][2] - k));
            if (k < c.size())
              dp[i][j][k + 1][1] =
                  min(dp[i][j][k + 1][1], dp[i][j][k][t] +
                                              max(0, cnt[c[k] - 1][0] - i) +
                                              max(0, cnt[c[k] - 1][1] - j) +
                                              max(0, cnt[c[k] - 1][2] - k));
          }
      }
    }
  }
  printf("%d\n", min(dp[a.size()][b.size()][c.size()][0],
                     dp[a.size()][b.size()][c.size()][1]));
  return 0;
}
