#include <bits/stdc++.h>
using namespace std;
int n, ans, len, sum1, sum2, sum3, f[100][100][100][2];
char s[100005];
int main() {
  scanf("%d", &n);
  while (!len) scanf("%s", s), len = strlen(s);
  for (int i = 0; i < len; i++) {
    if (s[i] == 'V')
      ++sum1;
    else if (s[i] == 'K')
      ++sum2;
    else
      ++sum3;
  }
  for (int a = 0; a <= sum1; a++)
    for (int b = 0; b <= sum2; b++)
      for (int c = 0; c <= sum3; c++)
        for (int d = 0; d < 2; d++) f[a][b][c][d] = 100000000;
  f[0][0][0][0] = 0;
  for (int a = 0; a <= sum1; a++)
    for (int b = 0; b <= sum2; b++)
      for (int c = 0; c <= sum3; c++)
        for (int d = 0; d < 2; d++) {
          int aa = a, bb = b, cc = c, i = 1, a1 = 0, b1 = 0, c1 = 0;
          for (; i <= n; i++) {
            if (s[i - 1] == 'V') {
              if (aa == 0) {
                if (a1 == 0)
                  f[a + 1][b][c][1] =
                      min(f[a + 1][b][c][1], f[a][b][c][d] + b1 + c1 + a1);
                ++a1;
              } else
                --aa;
            } else if (s[i - 1] == 'K') {
              if (bb == 0) {
                if (b1 == 0 && d == 0)
                  f[a][b + 1][c][0] =
                      min(f[a][b + 1][c][0], f[a][b][c][d] + b1 + c1 + a1);
                ++b1;
              } else
                --bb;
            } else {
              if (cc == 0) {
                if (c1 == 0)
                  f[a][b][c + 1][0] =
                      min(f[a][b][c + 1][0], f[a][b][c][d] + b1 + c1 + a1);
                ++c1;
              } else
                --cc;
            }
          }
        }
  ans = min(f[sum1][sum2][sum3][0], f[sum1][sum2][sum3][1]);
  printf("%d", ans);
}
