#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
map<string, int> my;
pair<string, int> getK(string s, int cntK) {
  int answer = 0;
  while (cntK > 0) {
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'K') {
        int j = i;
        while (j > 0) swap(s[j], s[j - 1]), --j, ++answer;
        break;
      }
    }
    s.erase(0, 1);
    --cntK;
  }
  return make_pair(s, answer);
}
pair<string, int> getV(string s, int cntV) {
  int answer = 0;
  while (cntV > 0) {
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'V') {
        int j = i;
        while (j > 0) swap(s[j], s[j - 1]), --j, ++answer;
        break;
      }
    }
    s.erase(0, 1);
    --cntV;
  }
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != 'V' && s[i] != 'K') {
      int j = i;
      while (j > 0) swap(s[j], s[j - 1]), --j, ++answer;
      break;
    }
  }
  s.erase(0, 1);
  return make_pair(s, answer);
}
int f(string s) {
  if (my.find(s) != my.end()) return my[s];
  bool ok = true;
  for (int i = 0; i + 1 < s.size(); ++i) {
    if (s[i] == 'V' && s[i + 1] == 'K') ok = false;
  }
  if (ok) {
    my[s] = 0;
    return my[s];
  }
  int cntK = 0, cntV = 0, cntOst = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'V')
      ++cntV;
    else if (s[i] == 'K')
      ++cntK;
    else
      ++cntOst;
  }
  int ans = INF;
  for (int cV = 0; cV <= cntV; ++cV) {
    if (cntOst == 0 && cntK > 0) continue;
    pair<string, int> cur = getV(s, cV);
    if (cur.second > ans) continue;
    cur.second += f(cur.first);
    if (cur.second < ans) ans = cur.second;
  }
  for (int cK = 1; cK <= cntK; ++cK) {
    pair<string, int> cur = getK(s, cK);
    if (cur.second > ans) continue;
    cur.second += f(cur.first);
    if (cur.second < ans) ans = cur.second;
  }
  my[s] = ans;
  return my[s];
}
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  cout << f(s) << endl;
  return 0;
}
