#include <bits/stdc++.h>
using namespace std;
int dp[76][76][76][2];
vector<int> ind[3];
string s;
int find(int to, int i, int j, int k) {
  int a = 0, b = 0, c = 0;
  for (int z = 0; z < to; z++)
    if (s[z] == 'V')
      a++;
    else if (s[z] == 'K')
      b++;
    else
      c++;
  return max(0, i - a) + max(0, j - b) + max(0, k - c);
}
int main() {
  int n;
  scanf("%d", &n);
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'V')
      ind[0].push_back(i);
    else if (s[i] == 'K')
      ind[1].push_back(i);
    else
      ind[2].push_back(i);
  }
  for (int i = 0; i < 3; i++) {
    sort(ind[i].begin(), ind[i].end());
    ind[i].push_back(-1);
  }
  for (int i = 0; i < ind[0].size(); i++)
    for (int j = 0; j < ind[1].size(); j++)
      for (int k = 0; k < ind[2].size(); k++)
        for (int is = 0; is < 2; is++) dp[i][j][k][is] = 1e9;
  dp[0][0][0][0] = 0;
  for (int i = 0; i < ind[0].size(); i++)
    for (int j = 0; j < ind[1].size(); j++)
      for (int k = 0; k < ind[2].size(); k++)
        for (int is = 0; is < 2; is++) {
          if (ind[0].size() > i && ind[0][i] != -1) {
            int at = ind[0][i];
            at += find(at, i, j, k);
            dp[i + 1][j][k][1] =
                min(dp[i + 1][j][k][1], dp[i][j][k][is] + abs(at - i - j - k));
          }
          if (ind[2].size() > k && ind[2][k] != -1) {
            int at = ind[2][k];
            at += find(at, i, j, k);
            dp[i][j][k + 1][0] =
                min(dp[i][j][k + 1][0], dp[i][j][k][is] + abs(at - i - j - k));
          }
          if (ind[1].size() > j && ind[1][j] != -1 && !is) {
            int at = ind[1][j];
            at += find(at, i, j, k);
            dp[i][j + 1][k][0] =
                min(dp[i][j + 1][k][0], dp[i][j][k][is] + abs(at - i - j - k));
          }
        }
  printf("%d\n",
         min(dp[ind[0].size() - 1][ind[1].size() - 1][ind[2].size() - 1][0],
             dp[ind[0].size() - 1][ind[1].size() - 1][ind[2].size() - 1][1]));
}
