#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vv, vk, vx;
const int N = 77;
const int INF = 0x3f3f3f3f;
int dp[N][N][N][2];
int count_remaining(const vector<int> &vat, int from, int to) {
  int cnt = 0;
  for (int i = from; i < (int)vat.size() && vat[i] < to; ++i) {
    ++cnt;
  }
  return cnt;
}
int moving_cost(int where, int v, int k, int x) {
  return count_remaining(vv, v, where) + count_remaining(vk, k, where) +
         count_remaining(vx, x, where);
}
void chk_min(int &a, int b) { a = min(a, b); }
int main() {
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'V') {
      vv.push_back(i);
    } else if (s[i] == 'K') {
      vk.push_back(i);
    } else {
      vx.push_back(i);
    }
  }
  for (int a = 0; a <= n; ++a) {
    for (int b = 0; b <= n; ++b) {
      for (int c = 0; c <= n; ++c) {
        for (int d = 0; d < 2; ++d) {
          dp[a][b][c][d] = INF;
        }
      }
    }
  }
  dp[0][0][0][0] = 0;
  int sz_v = vv.size();
  int sz_k = vk.size();
  int sz_x = vx.size();
  for (int v = 0; v <= sz_v; ++v) {
    for (int k = 0; k <= sz_k; ++k) {
      for (int x = 0; x <= sz_x; ++x) {
        for (int type = 0; type < 2; ++type) {
          int atual = dp[v][k][x][type];
          if (v < sz_v) {
            chk_min(dp[v + 1][k][x][1], atual + moving_cost(vv[v], v, k, x));
          }
          if (k < sz_k && type == 0) {
            chk_min(dp[v][k + 1][x][0], atual + moving_cost(vk[k], v, k, x));
          }
          if (x < sz_x) {
            chk_min(dp[v][k][x + 1][0], atual + moving_cost(vx[x], v, k, x));
          }
        }
      }
    }
  }
  int answer = INF;
  for (int i = 0; i < 2; ++i) {
    chk_min(answer, dp[sz_v][sz_k][sz_x][i]);
  }
  cout << answer << endl;
}
