#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f;
const long long INFL = (long long)1E18;
const int dir[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int dp[80][80][80][2];
int vs[80];
int ks[80];
int xs[80];
vector<int> vidx;
vector<int> kidx;
vector<int> xidx;
int V, K, X;
int n;
string line;
int main() {
  cin >> n;
  cin >> line;
  vs[0] = ks[0] = xs[0] = 0;
  for (int i = (0); i < (n); i++) {
    vs[i + 1] = vs[i];
    ks[i + 1] = ks[i];
    xs[i + 1] = xs[i];
    if (line[i] == 'V') {
      vs[i + 1] += 1;
      vidx.push_back(i);
    } else if (line[i] == 'K') {
      ks[i + 1] += 1;
      kidx.push_back(i);
    } else {
      xs[i + 1] += 1;
      xidx.push_back(i);
    }
  }
  V = vs[n];
  K = ks[n];
  X = xs[n];
  memset(dp, INF, sizeof(dp));
  dp[0][0][0][0] = dp[0][0][0][1] = 0;
  for (int i = (0); i < (V + 1); i++) {
    for (int j = (0); j < (K + 1); j++) {
      for (int k = (0); k < (X + 1); k++) {
        if (i > 0) {
          int idx = vidx[i - 1];
          dp[i][j][k][1] = dp[i - 1][j][k][0] + max(0, vs[idx] - (i - 1)) +
                           max(0, ks[idx] - j) + max(0, xs[idx] - k);
          dp[i][j][k][1] = min(dp[i][j][k][1],
                               dp[i - 1][j][k][1] + max(0, vs[idx] - (i - 1)) +
                                   max(0, ks[idx] - j) + max(0, xs[idx] - k));
        }
        if (j > 0) {
          int idx = kidx[j - 1];
          dp[i][j][k][0] = dp[i][j - 1][k][0] + max(0, vs[idx] - i) +
                           max(0, ks[idx] - (j - 1)) + max(0, xs[idx] - k);
        }
        if (k > 0) {
          int idx = xidx[k - 1];
          dp[i][j][k][0] =
              min(dp[i][j][k][0], dp[i][j][k - 1][0] + max(0, vs[idx] - i) +
                                      max(0, ks[idx] - j) +
                                      max(0, xs[idx] - (k - 1)));
          dp[i][j][k][0] =
              min(dp[i][j][k][0], dp[i][j][k - 1][1] + max(0, vs[idx] - i) +
                                      max(0, ks[idx] - j) +
                                      max(0, xs[idx] - (k - 1)));
        }
      }
    }
  }
  cout << min(dp[V][K][X][0], dp[V][K][X][1]) << endl;
  return 0;
}
