#include <bits/stdc++.h>
using namespace std;
int n, V = 0, K = 0, X = 0, cv[100], ck[100], cx[100], pv[100], pk[100],
       px[100], f[100][100][100][2];
int MAX(int pos, int v, int k, int x) {
  return max(v - cv[pos], 0) + max(k - ck[pos], 0) + max(x - cx[pos], 0);
}
int main() {
  cin >> n;
  char c;
  for (int i = 1; i <= n; i++) {
    cin >> c;
    cv[i] = cv[i - 1];
    ck[i] = ck[i - 1];
    cx[i] = cx[i - 1];
    if (c == 'V') {
      cv[i]++;
      pv[++V] = i;
    } else if (c == 'K') {
      ck[i]++;
      pk[++K] = i;
    } else {
      cx[i]++;
      px[++X] = i;
    }
  }
  for (int v = 0; v <= V; v++)
    for (int k = 0; k <= K; k++)
      for (int x = 0; x <= X; x++) {
        f[v][k][x][0] = 1e9;
        f[v][k][x][1] = 1e9;
      }
  f[0][0][0][0] = 0;
  for (int v = 0; v <= V; v++)
    for (int k = 0; k <= K; k++)
      for (int x = 0; x <= X; x++) {
        if (v > 0)
          f[v][k][x][1] =
              min(f[v][k][x][1],
                  min(f[v - 1][k][x][0], f[v - 1][k][x][1]) +
                      abs(v + k + x - pv[v] - MAX(pv[v], v - 1, k, x)));
        if (k > 0)
          f[v][k][x][0] = min(f[v][k][x][0],
                              f[v][k - 1][x][0] + abs(v + k + x - pk[k] -
                                                      MAX(pk[k], v, k - 1, x)));
        if (x > 0)
          f[v][k][x][0] =
              min(f[v][k][x][0],
                  min(f[v][k][x - 1][0], f[v][k][x - 1][1]) +
                      abs(v + k + x - px[x] - MAX(px[x], v, k, x - 1)));
      }
  cout << min(f[V][K][X][0], f[V][K][X][1]);
}
