#include <bits/stdc++.h>
using namespace std;
long long int Pow(long long int a, long long int b, long long int md,
                  long long int ans = 1) {
  for (; b; b >>= 1, a = a * a % md)
    if (b & 1) ans = ans * a % md;
  return ans % md;
}
const long long int MAXN = 110;
const long long int INF = 1e18;
const long long int MOD = 1e9 + 7;
long long int dp[MAXN][MAXN][MAXN][3], A[MAXN], n;
vector<long long int> pos[3];
char C[MAXN];
int main() {
  scanf("%lld%s", &n, C + 1);
  for (long long int i = 1; i <= n; i++) {
    if (C[i] == 'V')
      pos[0].push_back(i);
    else if (C[i] == 'K')
      pos[1].push_back(i);
    else
      pos[2].push_back(i);
  }
  fill(&dp[0][0][0][0], &dp[0][0][0][0] + MAXN * MAXN * MAXN * 3, INF);
  dp[0][0][0][0] = 0;
  for (long long int i = 0; i <= (long long int)pos[0].size(); i++) {
    for (long long int j = 0; j <= (long long int)pos[1].size(); j++) {
      for (long long int k = 0; k <= (long long int)pos[2].size(); k++) {
        for (long long int t = 0; t < 2; t++) {
          if (i + 1 <= (long long int)pos[0].size()) {
            long long int c1 =
                max(lower_bound((pos[0]).begin(), (pos[0]).end(), pos[0][i]) -
                        pos[0].begin() - i,
                    0LL);
            long long int c2 =
                max(lower_bound((pos[1]).begin(), (pos[1]).end(), pos[0][i]) -
                        pos[1].begin() - j,
                    0LL);
            long long int c3 =
                max(lower_bound((pos[2]).begin(), (pos[2]).end(), pos[0][i]) -
                        pos[2].begin() - k,
                    0LL);
            dp[i + 1][j][k][1] =
                min(dp[i + 1][j][k][1], dp[i][j][k][t] + c1 + c2 + c3);
          }
          if (j + 1 <= (long long int)pos[1].size() && !t) {
            long long int c1 =
                max(lower_bound((pos[0]).begin(), (pos[0]).end(), pos[1][j]) -
                        pos[0].begin() - i,
                    0LL);
            long long int c2 =
                max(lower_bound((pos[1]).begin(), (pos[1]).end(), pos[1][j]) -
                        pos[1].begin() - j,
                    0LL);
            long long int c3 =
                max(lower_bound((pos[2]).begin(), (pos[2]).end(), pos[1][j]) -
                        pos[2].begin() - k,
                    0LL);
            dp[i][j + 1][k][0] =
                min(dp[i][j + 1][k][0], dp[i][j][k][t] + c1 + c2 + c3);
          }
          if (k + 1 <= (long long int)pos[2].size()) {
            long long int c1 =
                max(lower_bound((pos[0]).begin(), (pos[0]).end(), pos[2][k]) -
                        pos[0].begin() - i,
                    0LL);
            long long int c2 =
                max(lower_bound((pos[1]).begin(), (pos[1]).end(), pos[2][k]) -
                        pos[1].begin() - j,
                    0LL);
            long long int c3 =
                max(lower_bound((pos[2]).begin(), (pos[2]).end(), pos[2][k]) -
                        pos[2].begin() - k,
                    0LL);
            dp[i][j][k + 1][0] =
                min(dp[i][j][k + 1][0], dp[i][j][k][t] + c1 + c2 + c3);
          }
        }
      }
    }
  }
  printf("%lld\n",
         min(dp[(long long int)pos[0].size()][(long long int)pos[1].size()]
               [(long long int)pos[2].size()][0],
             dp[(long long int)pos[0].size()][(long long int)pos[1].size()]
               [(long long int)pos[2].size()][1]));
  return 0;
}
