#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int N = 85;
int n, f[N][N][N][2], pos[3][N], cnt[3], num[3][N];
string s;
int getType(char c) {
  if (c == 'V') return 1;
  if (c == 'K') return 2;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    int t = getType(s[i]);
    pos[t][cnt[t]] = i;
    ++cnt[t];
  }
  for (int x = 0; x < (3); ++x)
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (i); ++j) {
        int t = getType(s[j]);
        if (t == x) ++num[x][i];
      }
    }
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (N); ++j)
      for (int w = 0; w < (N); ++w)
        for (int x = 0; x < (2); ++x) f[i][j][w][x] = inf;
  f[0][0][0][0] = 0;
  for (int x = 0; x < (cnt[0] + 1); ++x)
    for (int y = 0; y < (cnt[1] + 1); ++y)
      for (int z = 0; z < (cnt[2] + 1); ++z)
        for (int w = 0; w < (2); ++w) {
          if (f[x][y][z][w] == inf) {
            continue;
          }
          f[x + 1][y][z][0] = min(
              f[x + 1][y][z][0],
              f[x][y][z][w] + abs(x + y + z -
                                  (pos[0][x] + max(0, y - num[1][pos[0][x]]) +
                                   max(0, z - num[2][pos[0][x]]))));
          f[x][y + 1][z][1] = min(
              f[x][y + 1][z][1],
              f[x][y][z][w] + abs(x + y + z -
                                  (pos[1][y] + max(0, x - num[0][pos[1][y]]) +
                                   max(0, z - num[2][pos[1][y]]))));
          if (!w)
            f[x][y][z + 1][0] = min(
                f[x][y][z + 1][0],
                f[x][y][z][w] + abs(x + y + z -
                                    (pos[2][z] + max(0, x - num[0][pos[2][z]]) +
                                     max(0, y - num[1][pos[2][z]]))));
        }
  cout << min(f[cnt[0]][cnt[1]][cnt[2]][0], f[cnt[0]][cnt[1]][cnt[2]][1])
       << endl;
  return 0;
}
