#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int dp[80][80][80][2];
char c[80];
vector<int> V, K, a;
int cal(int id, vector<int> vv, int pos) {
  int cnt = 0;
  for (int i = id; i < ((int)vv.size()); i++)
    if (vv[i] < pos) cnt++;
  return cnt;
}
int cc(int i, int j, int k, int pos) {
  return cal(i, V, pos) + cal(j, K, pos) + cal(k, a, pos);
}
void mi(int &a, int b) {
  if (a > b) a = b;
}
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", c);
  for (int i = 0; i < n; i++) {
    if (c[i] == 'V')
      V.push_back(i);
    else if (c[i] == 'K')
      K.push_back(i);
    else
      a.push_back(i);
  }
  for (int i = 0; i <= ((int)V.size()); i++)
    for (int j = 0; j <= ((int)K.size()); j++)
      for (int k = 0; k <= ((int)a.size()); k++)
        for (int l = 0; l < 2; l++) dp[i][j][k][l] = INF;
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= ((int)V.size()); i++)
    for (int j = 0; j <= ((int)K.size()); j++)
      for (int k = 0; k <= ((int)a.size()); k++)
        for (int l = 0; l < 2; l++) {
          if (i + 1 <= ((int)V.size()))
            mi(dp[i + 1][j][k][1], dp[i][j][k][l] + cc(i, j, k, V[i]));
          if (j + 1 <= ((int)K.size()) && l == 0)
            mi(dp[i][j + 1][k][0], dp[i][j][k][l] + cc(i, j, k, K[j]));
          if (k + 1 <= ((int)a.size()))
            mi(dp[i][j][k + 1][0], dp[i][j][k][l] + cc(i, j, k, a[k]));
        }
  printf("%d\n", min(dp[((int)V.size())][((int)K.size())][((int)a.size())][0],
                     dp[((int)V.size())][((int)K.size())][((int)a.size())][1]));
  return 0;
}
