#include <bits/stdc++.h>
using namespace std;
vector<int> V, K, A;
int dp[76][76][76][2];
int left_chars(int v, int k, int a, int cut) {
  int ret = 0;
  for (int i = v; i < V.size(); i++) {
    if (V[i] < cut)
      ret++;
    else
      break;
  }
  for (int i = k; i < K.size(); i++) {
    if (K[i] < cut)
      ret++;
    else
      break;
  }
  for (int i = a; i < A.size(); i++) {
    if (A[i] < cut)
      ret++;
    else
      break;
  }
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  getchar();
  char c;
  for (int i = 1; i <= n; i++) {
    c = getchar();
    if (c == 'V')
      V.push_back(i);
    else if (c == 'K')
      K.push_back(i);
    else
      A.push_back(i);
  }
  memset(dp, 0x1f, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int v = 0; v <= V.size(); v++) {
    for (int k = 0; k <= K.size(); k++) {
      for (int a = 0; a <= A.size(); a++) {
        for (int type = 0; type < 2; type++) {
          int here = dp[v][k][a][type];
          if (v < V.size()) {
            dp[v + 1][k][a][1] =
                min(dp[v + 1][k][a][1], here + left_chars(v, k, a, V[v]));
          }
          if (k < K.size() && type == 0) {
            dp[v][k + 1][a][0] =
                min(dp[v][k + 1][a][0], here + left_chars(v, k, a, K[k]));
          }
          if (a < A.size()) {
            dp[v][k][a + 1][0] =
                min(dp[v][k][a + 1][0], here + left_chars(v, k, a, A[a]));
          }
        }
      }
    }
  }
  int result = 1e9;
  for (int i = 0; i < 2; i++)
    result = min(result, dp[V.size()][K.size()][A.size()][i]);
  printf("%d\n", result);
  return 0;
}
