#include <bits/stdc++.h>
using namespace std;
void Min(int &x, int y) {
  if ((x == -1 || x > y) && y != -1) x = y;
}
int dp[77][77][77][3], n;
char S[77], A[77];
void Init(int a, int b, int c) {
  for (int i = 1; i <= n; i++)
    if (S[i] == 'V') {
      if (a)
        A[i] = ' ', a--;
      else
        A[i] = 'V';
    } else if (S[i] == 'K') {
      if (b)
        A[i] = ' ', b--;
      else
        A[i] = 'K';
    } else {
      if (c)
        A[i] = ' ', c--;
      else
        A[i] = 'A';
    }
}
int main() {
  scanf("%d", &n), scanf("%s", S + 1);
  int cnt1 = 0, cnt2 = 0, cnt3 = 0;
  for (int i = 1; i <= n; i++)
    if (S[i] == 'V')
      cnt1++;
    else if (S[i] == 'K')
      cnt2++;
    else
      cnt3++;
  memset(dp, -1, sizeof(dp));
  dp[0][0][0][2] = 0;
  for (int i = 0; i <= cnt1; i++)
    for (int j = 0; j <= cnt2; j++)
      for (int k = 0; k <= cnt3; k++) {
        Init(i, j, k);
        int a = 0, b = 0, c = 0;
        for (int l = 1; l <= n; l++)
          if (A[l] == 'V')
            break;
          else if (A[l] != ' ')
            a++;
        for (int l = 1; l <= n; l++)
          if (A[l] == 'K')
            break;
          else if (A[l] != ' ')
            b++;
        for (int l = 1; l <= n; l++)
          if (A[l] == 'A')
            break;
          else if (A[l] != ' ')
            c++;
        if (dp[i][j][k][0] != -1) {
          Min(dp[i + 1][j][k][0], dp[i][j][k][0] + a);
          Min(dp[i][j][k + 1][2], dp[i][j][k][0] + c);
        }
        if (dp[i][j][k][1] != -1) {
          Min(dp[i + 1][j][k][0], dp[i][j][k][1] + a);
          Min(dp[i][j + 1][k][1], dp[i][j][k][1] + b);
          Min(dp[i][j][k + 1][2], dp[i][j][k][1] + c);
        }
        if (dp[i][j][k][2] != -1) {
          Min(dp[i + 1][j][k][0], dp[i][j][k][2] + a);
          Min(dp[i][j + 1][k][1], dp[i][j][k][2] + b);
          Min(dp[i][j][k + 1][2], dp[i][j][k][2] + c);
        }
      }
  Min(dp[cnt1][cnt2][cnt3][0], dp[cnt1][cnt2][cnt3][1]);
  Min(dp[cnt1][cnt2][cnt3][0], dp[cnt1][cnt2][cnt3][2]);
  printf("%d\n", dp[cnt1][cnt2][cnt3][0]);
  return 0;
}
