#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int N, arr[maxn], dp[maxn][maxn][maxn][3];
vector<int> pos[3];
bool marked[maxn];
inline int calc(int a, vector<int> &v) {
  int cnt = 0;
  for (int ck : v) cnt += ck <= a;
  return cnt;
}
int solve(int a[3], int lst) {
  if (a[0] + a[1] + a[2] == 0) return 0;
  if (dp[a[0]][a[1]][a[2]][lst] != -1) return dp[a[0]][a[1]][a[2]][lst];
  int res = 0x3f3f3f3f;
  memset(marked, 0, sizeof marked);
  for (int i = 0; i < 3; i++)
    for (int k = 0; k < a[i]; k++) marked[pos[i][k]] = true;
  vector<int> v;
  for (int i = 1; i <= N; i++)
    if (!marked[i]) v.push_back(i);
  for (int p = 0; p < 3; p++) {
    if (p == 0 && lst == 1 || !a[p]) continue;
    int pp = pos[p][--a[p]], cc = calc(pp, v);
    res = min(res, solve(a, p) + cc);
    a[p]++;
  }
  return dp[a[0]][a[1]][a[2]][lst] = res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    char c;
    cin >> c;
    if (c == 'V')
      arr[i] = 0;
    else if (c == 'K')
      arr[i] = 1;
    else
      arr[i] = 2;
    pos[arr[i]].push_back(i);
  }
  memset(dp, -1, sizeof dp);
  int res = 0x3f3f3f3f, tmp[3];
  for (int i = 0; i < 3; i++) tmp[i] = (int)pos[i].size();
  for (int i = 0; i < 3; i++) {
    if (!tmp[i]) continue;
    tmp[i]--;
    res = min(res, solve(tmp, i));
    tmp[i]++;
  }
  cout << res << endl;
}
