#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
const int LG = 19;
vector<int> V;
vector<int> X;
vector<int> K;
int dp[76][76][76][2];
int rem(vector<int>& l, int from, int lim) {
  int cnt = 0;
  for (int i = from; i < l.size() && l[i] < lim; ++i) cnt++;
  return cnt;
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'K')
      K.push_back(i);
    else if (s[i] == 'V')
      V.push_back(i);
    else
      X.push_back(i);
  }
  for (int v = 0; v < n; ++v)
    for (int x = 0; x < n; ++x)
      for (int k = 0; k < n; ++k)
        for (int i = 0; i < 2; ++i) dp[v][x][k][i] = 10000000;
  dp[0][0][0][0] = 0;
  for (int v = 0; v < V.size() + 1; ++v)
    for (int x = 0; x < X.size() + 1; ++x)
      for (int k = 0; k < K.size() + 1; ++k)
        for (int i = 0; i < 2; ++i) {
          auto moving_cost = [&](int where) {
            return rem(K, k, where) + rem(V, v, where) + rem(X, x, where);
          };
          if (v < V.size()) {
            dp[v + 1][k][x][1] =
                min(dp[v + 1][k][x][1], dp[v][k][x][i] + moving_cost(V[v]));
          }
          if (k < K.size() && i == 0)
            dp[v][k + 1][x][0] =
                min(dp[v][k + 1][x][0], dp[v][k][x][i] + moving_cost(K[k]));
          if (x < X.size())
            dp[v][k][x + 1][0] =
                min(dp[v][k][x + 1][0], dp[v][k][x][i] + moving_cost(X[x]));
        }
  int ans = min(dp[V.size()][K.size()][X.size()][0],
                dp[V.size()][K.size()][X.size()][1]);
  cout << ans;
}
