#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, ans;
int dp[77][77][77][2];
string s;
vector<int> V, K, O;
void mini(int &a, int b) { a = min(a, b); }
int count_remaining(const vector<int> &List, int from, int limit_val) {
  int cnt = 0;
  for (int i = from; i < List.size() && List[i] < limit_val; ++i) ++cnt;
  return cnt;
}
void init() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    switch (s[i]) {
      case 'V':
        V.push_back(i);
        break;
      case 'K':
        K.push_back(i);
        break;
      default:
        O.push_back(i);
        break;
    }
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k)
        for (int z = 0; z < 2; ++z) dp[i][j][k][z] = INF;
  dp[0][0][0][0] = 0;
}
void process() {
  for (int v = 0; v <= (int)V.size(); ++v)
    for (int k = 0; k <= (int)K.size(); ++k)
      for (int o = 0; o <= (int)O.size(); ++o)
        for (int type = 0; type < 2; ++type) {
          auto moving_cost = [&](int where) {
            return count_remaining(V, v, where) + count_remaining(K, k, where) +
                   count_remaining(O, o, where);
          };
          int already = dp[v][k][o][type];
          if (v < (int)V.size())
            mini(dp[v + 1][k][o][1], already + moving_cost(V[v]));
          if (k < (int)K.size() && type == 0)
            mini(dp[v][k + 1][o][0], already + moving_cost(K[k]));
          if (o < (int)O.size())
            mini(dp[v][k][o + 1][0], already + moving_cost(O[o]));
        }
  ans = INF;
  for (int i = 0; i < 2; ++i) {
    mini(ans, dp[V.size()][K.size()][O.size()][i]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  init();
  process();
  cout << ans << '\n';
  return 0;
}
