#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int nxt[300][300], n, cnt[300], dp[80][80][80][3], res = INF;
string s;
vector<int> X, K, V;
int cal(int stK, int stV, int stX, int lim) {
  int cnt = 0;
  for (int i = stK; i < K.size(); ++i)
    if (K[i] < lim)
      cnt++;
    else
      break;
  for (int i = stV; i < V.size(); ++i)
    if (V[i] < lim)
      cnt++;
    else
      break;
  for (int i = stX; i < X.size(); ++i)
    if (X[i] < lim)
      cnt++;
    else
      break;
  return cnt;
}
void Solve() {
  cin >> n;
  cin >> s;
  s = ' ' + s;
  for (int i = 1; i <= n; ++i)
    if (s[i] != 'K' && s[i] != 'V') s[i] = 'X';
  for (int i = 1; i <= n; ++i) {
    cnt[s[i]]++;
    if (s[i] == 'X')
      X.push_back(i);
    else if (s[i] == 'K')
      K.push_back(i);
    else
      V.push_back(i);
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0][1] = 0;
  for (int numK = 0; numK <= cnt['K']; ++numK)
    for (int numV = 0; numV <= cnt['V']; ++numV)
      for (int numX = 0; numX <= cnt['X']; ++numX)
        for (int last = 0; last <= 1; ++last) {
          int &ans = dp[numK][numV][numX][last];
          if (ans != INF) {
            if (numV + 1 <= cnt['V'])
              dp[numK][numV + 1][numX][0] =
                  min(dp[numK][numV + 1][numX][0],
                      ans + cal(numK, numV, numX, V[numV]));
            if (numX + 1 <= cnt['X'])
              dp[numK][numV][numX + 1][1] =
                  min(dp[numK][numV][numX + 1][1],
                      ans + cal(numK, numV, numX, X[numX]));
            if (last != 0)
              if (numK + 1 <= cnt['K'])
                dp[numK + 1][numV][numX][1] =
                    min(dp[numK + 1][numV][numX][1],
                        ans + cal(numK, numV, numX, K[numK]));
          }
        }
  for (int i = 0; i <= 1; ++i)
    res = min(res, dp[cnt['K']][cnt['V']][cnt['X']][i]);
  cout << res;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
