#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const long long oo = 1 << 30;
const long long loo = 1ll << 62;
const long long mods = 998244353;
const long long MAXN = 200005;
const long long INF = 0x3f3f3f3f;
inline long long read() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
char st[80];
vector<long long> V, K, O;
long long f[80][80][80][2];
long long get(long long x, long long y, long long z, long long pos) {
  long long num = 0;
  for (long long i = 0; i < x; i++)
    if (V[i] > pos) num++;
  for (long long i = 0; i < y; i++)
    if (K[i] > pos) num++;
  for (long long i = 0; i < z; i++)
    if (O[i] > pos) num++;
  return num;
}
signed main() {
  long long n = read();
  scanf("%s", st);
  for (long long i = 0; i < n; i++) {
    if (st[i] == 'V')
      V.push_back(i);
    else if (st[i] == 'K')
      K.push_back(i);
    else
      O.push_back(i);
  }
  for (long long i = 0; i <= V.size(); i++)
    for (long long j = 0; j <= K.size(); j++)
      for (long long k = 0; k <= O.size(); k++)
        f[i][j][k][0] = f[i][j][k][1] = INF;
  f[0][0][0][0] = 0;
  for (long long i = 0; i <= V.size(); i++)
    for (long long j = 0; j <= K.size(); j++)
      for (long long k = 0; k <= O.size(); k++) {
        if (i < V.size())
          upmin(f[i + 1][j][k][1], f[i][j][k][0] + get(i, j, k, V[i]));
        if (i < V.size())
          upmin(f[i + 1][j][k][1], f[i][j][k][1] + get(i, j, k, V[i]));
        if (j < K.size())
          upmin(f[i][j + 1][k][0], f[i][j][k][0] + get(i, j, k, K[j]));
        if (k < O.size())
          upmin(f[i][j][k + 1][0], f[i][j][k][0] + get(i, j, k, O[k]));
        if (k < O.size())
          upmin(f[i][j][k + 1][0], f[i][j][k][1] + get(i, j, k, O[k]));
      }
  printf("%d\n", min(f[V.size()][K.size()][O.size()][0],
                     f[V.size()][K.size()][O.size()][1]));
  return 0;
}
