#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 75;
int n;
char a[N + 5];
int dp[N + 1][N + 1][N + 1][3];
int grtV[N + 1][N + 1], grtK[N + 1][N + 1], grtA[N + 1][N + 1];
int val(int v, int x, int y, int z) {
  return grtV[v][x] + grtK[v][y] + grtA[v][z];
}
int main() {
  cin >> n >> a + 1;
  vector<int> V, K, A;
  for (int i = 1; i <= n; i++)
    if (a[i] == 'V')
      V.push_back(i);
    else if (a[i] == 'K')
      K.push_back(i);
    else
      A.push_back(i);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= V.size(); j++)
      for (int k = 0; k < j; k++) grtV[i][j] += V[k] > i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= K.size(); j++)
      for (int k = 0; k < j; k++) grtK[i][j] += K[k] > i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= A.size(); j++)
      for (int k = 0; k < j; k++) grtA[i][j] += A[k] > i;
  for (int i = 0; i <= V.size(); i++)
    for (int j = 0; j <= K.size(); j++)
      for (int k = 0; k <= A.size(); k++)
        if (i || j || k)
          for (int o = 0; o < 3; o++) {
            dp[i][j][k][o] = inf;
            if (o == 0 && !i || o == 1 && !j || o == 2 && !k) continue;
            if (o == 0) {
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i - 1][j][k][0] + val(V[i - 1], i - 1, j, k));
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i - 1][j][k][1] + val(V[i - 1], i - 1, j, k));
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i - 1][j][k][2] + val(V[i - 1], i - 1, j, k));
            } else if (o == 1) {
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i][j - 1][k][1] + val(K[j - 1], i, j - 1, k));
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i][j - 1][k][2] + val(K[j - 1], i, j - 1, k));
            } else {
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i][j][k - 1][0] + val(A[k - 1], i, j, k - 1));
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i][j][k - 1][1] + val(A[k - 1], i, j, k - 1));
              dp[i][j][k][o] =
                  min(dp[i][j][k][o],
                      dp[i][j][k - 1][2] + val(A[k - 1], i, j, k - 1));
            }
          }
  int *head = dp[V.size()][K.size()][A.size()];
  cout << min(min(head[0], head[1]), head[2]);
  return 0;
}
