#include <bits/stdc++.h>
using namespace std;
long long n, d[2][77][77][77], cnt[3][77], calc, pos;
vector<long long> v[3];
char c[111];
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
    for (long long j = 0; j < 3; j++) cnt[j][i] = cnt[j][i - 1];
    if (c[i] == 'V')
      cnt[0][i]++, v[0].push_back(i);
    else if (c[i] == 'K')
      cnt[1][i]++, v[1].push_back(i);
    else
      cnt[2][i]++, v[2].push_back(i);
  }
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= n; j++)
      for (long long k = 0; k <= n; k++) d[0][i][j][k] = d[1][i][j][k] = 2e9;
  d[0][0][0][0] = 0;
  for (long long i = 0; i <= cnt[0][n]; i++)
    for (long long j = 0; j <= cnt[1][n]; j++)
      for (long long k = 0; k <= cnt[2][n]; k++)
        if (min(d[0][i][j][k], d[1][i][j][k]) < 2e9) {
          if (i < cnt[0][n]) {
            pos = v[0][i];
            calc = pos - i - 1 - min(cnt[1][pos], j) - min(cnt[2][pos], k);
            d[1][i + 1][j][k] = min(d[1][i + 1][j][k],
                                    min(d[0][i][j][k], d[1][i][j][k]) + calc);
          }
          if (j < cnt[1][n]) {
            pos = v[1][j];
            calc = pos - j - 1 - min(cnt[0][pos], i) - min(cnt[2][pos], k);
            d[0][i][j + 1][k] = min(d[0][i][j + 1][k], d[0][i][j][k] + calc);
          }
          if (k < cnt[2][n]) {
            pos = v[2][k];
            calc = pos - k - 1 - min(cnt[1][pos], j) - min(cnt[0][pos], i);
            d[0][i][j][k + 1] = min(d[0][i][j][k + 1],
                                    min(d[0][i][j][k], d[1][i][j][k]) + calc);
          }
        }
  cout << min(d[0][cnt[0][n]][cnt[1][n]][cnt[2][n]],
              d[1][cnt[0][n]][cnt[1][n]][cnt[2][n]]);
}
