#include <bits/stdc++.h>
using namespace std;
int n, dp[80][80][80][2];
string s;
vector<int> vp, kp, xp;
int calc(int pos, int vi, int ki, int xi) {
  int lv = distance(vp.begin(), lower_bound(vp.begin(), vp.end(), pos));
  int lk = distance(kp.begin(), lower_bound(kp.begin(), kp.end(), pos));
  int lx = distance(xp.begin(), lower_bound(xp.begin(), xp.end(), pos));
  return max(lv - vi, 0) + max(lk - ki, 0) + max(lx - xi, 0);
}
int main(int argc, char** argv) {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'V')
      vp.push_back(i);
    else if (s[i] == 'K')
      kp.push_back(i);
    else
      xp.push_back(i);
  }
  for (int v = 0; v <= n; v++) {
    for (int k = 0; k <= n; k++) {
      for (int x = 0; x <= n; x++) dp[v][k][x][0] = dp[v][k][x][1] = 1 << 29;
    }
  }
  dp[0][0][0][0] = 0;
  for (int v = 0; v <= (int)vp.size(); v++) {
    for (int k = 0; k <= (int)kp.size(); k++) {
      for (int x = 0; x <= (int)xp.size(); x++) {
        for (int i = 0; i < 2; i++) {
          int cur = dp[v][k][x][i];
          if (v < (int)vp.size())
            dp[v + 1][k][x][1] =
                min(dp[v + 1][k][x][1], cur + calc(vp[v], v, k, x));
          if (!i && k < (int)kp.size())
            dp[v][k + 1][x][0] =
                min(dp[v][k + 1][x][0], cur + calc(kp[k], v, k, x));
          if (x < (int)xp.size())
            dp[v][k][x + 1][0] =
                min(dp[v][k][x + 1][0], cur + calc(xp[x], v, k, x));
        }
      }
    }
  }
  cout << min(dp[vp.size()][kp.size()][xp.size()][0],
              dp[vp.size()][kp.size()][xp.size()][1])
       << '\n';
  return 0;
}
