#include <bits/stdc++.h>
using namespace std;
int d[76][76][76][2];
char a[76], ch[4] = "VK?";
bool removed[76];
int remain;
int dp(int v, int k, int r, int forbid) {
  int& res = d[v][k][r][forbid];
  if (res != 0x3F3F3F3F) {
    return res;
  }
  if (remain == 0) {
    return res = 0;
  }
  for (int i = 0; i < 3; ++i) {
    if (ch[i] == 'K' && forbid) {
      continue;
    }
    int cnt = 0;
    for (int j = 0; a[j]; ++j) {
      if (!removed[j]) {
        if (a[j] == ch[i]) {
          removed[j] = true;
          --remain;
          res = min(res, dp(v + (ch[i] == 'V'), k + (ch[i] == 'K'),
                            r + (ch[i] == '?'), ch[i] == 'V') +
                             cnt);
          ++remain;
          removed[j] = false;
          break;
        }
        ++cnt;
      }
    }
  }
  return res;
}
int main() {
  scanf("%d%s", &remain, a);
  memset(d, 0x3F, sizeof(d));
  for (int i = 0; a[i]; ++i) {
    a[i] = a[i] == 'V' || a[i] == 'K' ? a[i] : '?';
  }
  printf("%d\n", dp(0, 0, 0, 0));
}
