#include <bits/stdc++.h>
using namespace std;
int n;
char s[81];
int a[81], c0, c1, c2, inf, ans;
int f[81][81][81][3];
void upd(int &x, int y) { x = min(x, y); }
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'K')
      c0++, a[i] = 0;
    else if (s[i] == 'V')
      c1++, a[i] = 1;
    else
      c2++, a[i] = 2;
  }
  memset(f, 0x3f, sizeof(f));
  inf = f[0][0][0][0];
  f[0][0][0][2] = 0;
  for (int i = 0; i <= c0; i++)
    for (int j = 0; j <= c1; j++)
      for (int k = 0; k <= c2; k++) {
        int v[3], p[3], cnt = 0;
        v[0] = i, v[1] = j, v[2] = k, p[0] = -1, p[1] = -1, p[2] = -1;
        for (int w = 1, t; w <= n; w++) {
          t = a[w];
          if (v[t])
            v[t]--;
          else {
            if (p[t] == -1) p[t] = cnt;
            cnt++;
          }
        }
        for (int w1 = 0; w1 <= 2; w1++)
          if (f[i][j][k][w1] != inf)
            for (int w2 = 0; w2 <= 2; w2++)
              if ((w1 != 1 || w2 != 0) && p[w2] != -1) {
                int i1 = (w2 == 0 ? i + 1 : i), j1 = (w2 == 1 ? j + 1 : j),
                    k1 = (w2 == 2 ? k + 1 : k);
                upd(f[i1][j1][k1][w2], f[i][j][k][w1] + p[w2]);
              }
      }
  ans = inf;
  for (int i = 0; i <= 2; i++) ans = min(ans, f[c0][c1][c2][i]);
  printf("%d\n", ans);
  return 0;
}
