#include <bits/stdc++.h>
using namespace std;
const int maxn = 77;
const int INF = 1e9 + 19;
int n;
string s;
vector<int> V, K, X;
int dp[maxn][maxn][maxn][2];
void ReadInput() {
  cin >> n;
  cin >> 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);
  }
}
int countRemaining(const vector<int>& lst, int from, int lim) {
  int cnt = 0;
  for (int i = from; i < (int)lst.size() && lst[i] < lim; ++i) ++cnt;
  return cnt;
}
inline void Minimize(int& tar, int val) { tar = min(tar, val); }
void Solve() {
  fill_n(&dp[0][0][0][0], sizeof(dp) / sizeof(dp[0][0][0][0]), INF);
  dp[0][0][0][0] = 0;
  for (int v = 0; v <= (int)V.size(); ++v)
    for (int k = 0; k <= (int)K.size(); ++k)
      for (int x = 0; x <= (int)X.size(); ++x)
        for (int type = 0; type < 2; ++type) {
          auto movingCost = [&](int pos) {
            return countRemaining(V, v, pos) + countRemaining(K, k, pos) +
                   countRemaining(X, x, pos);
          };
          int already = dp[v][k][x][type];
          if (v < (int)V.size())
            Minimize(dp[v + 1][k][x][1], already + movingCost(V[v]));
          if (k < (int)K.size() && type == 0)
            Minimize(dp[v][k + 1][x][0], already + movingCost(K[k]));
          if (x < (int)X.size())
            Minimize(dp[v][k][x + 1][0], already + movingCost(X[x]));
        }
  int ans = INF;
  for (int i = 0; i < 2; ++i)
    Minimize(ans, dp[V.size()][K.size()][X.size()][i]);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ReadInput();
  Solve();
}
