#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int INF = 1e+9;
const int LIM = 76;
const int V = 0;
const int K = 1;
const int O = 2;
int dp[LIM][LIM][LIM][3];
int get_cost(const string& s, int v, int k, int o, char need) {
  string rem = "";
  for (char c : s) {
    if (c == 'V') {
      if (v == 0)
        rem += c;
      else
        --v;
    } else if (c == 'K') {
      if (k == 0)
        rem += c;
      else
        --k;
    } else {
      if (o == 0)
        rem += c;
      else
        --o;
    }
  }
  int res = 0;
  for (char c : rem) {
    if (c != need)
      ++res;
    else
      break;
  }
  return res;
}
int main() {
  auto start = high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;
  for (char& c : s)
    if (c != 'V' && c != 'K') c = 'O';
  for (int v = 0; v < LIM; ++v)
    for (int k = 0; k < LIM; ++k)
      for (int o = 0; o < LIM; ++o)
        for (int last = 0; last < 3; ++last) dp[v][k][o][last] = -1;
  dp[0][0][0][K] = dp[0][0][0][O] = 0;
  int max_v = 0, max_k = 0, max_o = 0;
  for (char c : s) {
    if (c == 'V')
      ++max_v;
    else if (c == 'K')
      ++max_k;
    else
      ++max_o;
  }
  for (int v = 0; v <= max_v; ++v) {
    for (int k = 0; k <= max_k; ++k) {
      for (int o = 0; o <= max_o; ++o) {
        int cost_v = v + 1 <= max_v ? get_cost(s, v, k, o, 'V') : 0;
        int cost_k = k + 1 <= max_k ? get_cost(s, v, k, o, 'K') : 0;
        int cost_o = o + 1 <= max_o ? get_cost(s, v, k, o, 'O') : 0;
        int cost;
        if (dp[v][k][o][V] != -1) {
          cost = dp[v][k][o][V] + cost_v;
          if (v + 1 <= max_v)
            dp[v + 1][k][o][V] =
                dp[v + 1][k][o][V] == -1 ? cost : min(cost, dp[v + 1][k][o][V]);
          cost = dp[v][k][o][V] + cost_o;
          if (o + 1 <= max_o)
            dp[v][k][o + 1][O] =
                dp[v][k][o + 1][O] == -1 ? cost : min(cost, dp[v][k][o + 1][O]);
        }
        if (dp[v][k][o][K] != -1) {
          cost = dp[v][k][o][K] + cost_v;
          if (v + 1 <= max_v)
            dp[v + 1][k][o][V] =
                dp[v + 1][k][o][V] == -1 ? cost : min(cost, dp[v + 1][k][o][V]);
          cost = dp[v][k][o][K] + cost_k;
          if (k + 1 <= max_k)
            dp[v][k + 1][o][K] =
                dp[v][k + 1][o][K] == -1 ? cost : min(cost, dp[v][k + 1][o][K]);
          cost = dp[v][k][o][K] + cost_o;
          if (o + 1 <= max_o)
            dp[v][k][o + 1][O] =
                dp[v][k][o + 1][O] == -1 ? cost : min(cost, dp[v][k][o + 1][O]);
        }
        if (dp[v][k][o][O] != -1) {
          cost = dp[v][k][o][O] + cost_v;
          if (v + 1 <= max_v)
            dp[v + 1][k][o][V] =
                dp[v + 1][k][o][V] == -1 ? cost : min(cost, dp[v + 1][k][o][V]);
          cost = dp[v][k][o][O] + cost_k;
          if (k + 1 <= max_k)
            dp[v][k + 1][o][K] =
                dp[v][k + 1][o][K] == -1 ? cost : min(cost, dp[v][k + 1][o][K]);
          cost = dp[v][k][o][O] + cost_o;
          if (o + 1 <= max_o)
            dp[v][k][o + 1][O] =
                dp[v][k][o + 1][O] == -1 ? cost : min(cost, dp[v][k][o + 1][O]);
        }
      }
    }
  }
  int ans = INF;
  for (int i = 0; i < 3; ++i)
    if (dp[max_v][max_k][max_o][i] != -1)
      ans = min(ans, dp[max_v][max_k][max_o][i]);
  cout << ans << endl;
  cerr << "Total execution time : "
       << duration_cast<milliseconds>(high_resolution_clock::now() - start)
              .count()
       << " ms" << endl;
  return 0;
}
