#include <bits/stdc++.h>
using namespace std;
int n, dp[76][76][76][5];
char s[1111];
vector<int> V, K, X;
int func(vector<int> A, int pos, int v, int k, int x) {
  int cnt = 0;
  for (int i = k; i < K.size(); i++) {
    if (K[i] < A[pos])
      cnt++;
    else
      break;
  }
  for (int i = x; i < X.size(); i++) {
    if (X[i] < A[pos])
      cnt++;
    else
      break;
  }
  for (int i = v; i < V.size(); i++) {
    if (V[i] < A[pos])
      cnt++;
    else
      break;
  }
  return cnt;
}
int main() {
  while (scanf("%d\n", &n) != EOF) {
    scanf("%s", s);
    V.clear();
    K.clear();
    X.clear();
    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);
      }
    }
    for (int v = 0; v <= V.size(); v++)
      for (int k = 0; k <= K.size(); k++)
        for (int x = 0; x <= X.size(); x++)
          for (int lastv = 0; lastv < 3; lastv++) {
            dp[v][k][x][lastv] = 1000000000;
            if (v == 0 && k == 0 && x == 0) {
              dp[v][k][x][lastv] = 0;
            } else {
              if (v - 1 >= 0 && lastv == 1) {
                int cnt = func(V, v - 1, v, k, x);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v - 1][k][x][0] + cnt);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v - 1][k][x][1] + cnt);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v - 1][k][x][2] + cnt);
              }
              if (k - 1 >= 0 && lastv == 2) {
                int cnt = func(K, k - 1, v, k, x);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v][k - 1][x][0] + cnt);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v][k - 1][x][2] + cnt);
              }
              if (x - 1 >= 0 && lastv == 0) {
                int cnt = func(X, x - 1, v, k, x);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v][k][x - 1][0] + cnt);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v][k][x - 1][1] + cnt);
                dp[v][k][x][lastv] =
                    min(dp[v][k][x][lastv], dp[v][k][x - 1][2] + cnt);
              }
            }
          }
    int ans = 1000000000;
    for (int i = 0; i < 3; i++) {
      ans = min(ans, dp[V.size()][K.size()][X.size()][i]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
