#include <bits/stdc++.h>
using namespace std;
void cmin(int& a, int b) {
  if (b < a) a = b;
}
const int N = 78, inf = 0x3f3f3f3f;
int dp[N][N][N][2];
vector<int> a[3];
int cnt(int i, int j, int k, int x) {
  return max(int(lower_bound(begin(a[0]), end(a[0]), x) - begin(a[0])) - i, 0) +
         max(int(lower_bound(begin(a[1]), end(a[1]), x) - begin(a[1])) - j, 0) +
         max(int(lower_bound(begin(a[2]), end(a[2]), x) - begin(a[2])) - k, 0);
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    auto& x = s[i];
    x = x == 'V' ? 1 : x == 'K' ? 2 : 0;
    a[x].push_back(i);
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0][0] = 0;
  for (int m = 0; m < n; ++m)
    for (int i = 0; i <= min(m, ((int)(a[0]).size())); ++i)
      for (int j = 0; j <= min(m - i, ((int)(a[1]).size())); ++j) {
        int k = m - i - j;
        for (int b = 0; b <= 1; ++b) {
          int od = dp[i][j][k][b];
          if (od == inf) continue;
          if (i != ((int)(a[0]).size()))
            cmin(dp[i + 1][j][k][0], od + cnt(i, j, k, a[0][i]));
          if (j != ((int)(a[1]).size()))
            cmin(dp[i][j + 1][k][1], od + cnt(i, j, k, a[1][j]));
          if (!b && k != ((int)(a[2]).size()))
            cmin(dp[i][j][k + 1][0], od + cnt(i, j, k, a[2][k]));
        }
      }
  cout << min(dp[((int)(a[0]).size())][((int)(a[1]).size())]
                [((int)(a[2]).size())][0],
              dp[((int)(a[0]).size())][((int)(a[1]).size())]
                [((int)(a[2]).size())][1])
       << endl;
}
