#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int v_tot = 0, k_tot = 0, x_tot = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'K') {
      k_tot++;
    } else if (s[i] == 'V') {
      v_tot++;
    } else {
      x_tot++;
      s[i] = 'X';
    }
  }
  int dp[k_tot + 1][v_tot + 1][x_tot + 1][2];
  for (int i = 0; i <= k_tot; i++)
    for (int j = 0; j <= v_tot; j++)
      for (int k = 0; k <= x_tot; k++) {
        dp[i][j][k][0] = INF;
        dp[i][j][k][1] = INF;
      }
  if (s[0] == 'V') dp[0][1][0][1] = 0;
  if (s[0] == 'K') dp[1][0][0][0] = 0;
  if (s[0] == 'X') dp[0][0][1][0] = 0;
  dp[0][0][0][0] = 0;
  for (int v = 0; v <= v_tot; v++) {
    for (int k = 0; k <= k_tot; k++) {
      for (int x = 0; x <= x_tot; x++) {
        int i = 0;
        int cnt_k = 0, cnt_v = 0, cnt_x = 0;
        int not_used = 0;
        while (i < n && cnt_k <= k) {
          if (s[i] == 'K') cnt_k++;
          if (s[i] == 'V') {
            if (cnt_v == v)
              not_used++;
            else
              cnt_v++;
          }
          if (s[i] == 'X') {
            if (cnt_x == x)
              not_used++;
            else
              cnt_x++;
          }
          i++;
        }
        if (k + 1 <= k_tot) {
          dp[k + 1][v][x][0] =
              min(dp[k + 1][v][x][0], dp[k][v][x][0] + not_used);
        }
        i = 0;
        cnt_k = 0;
        cnt_v = 0;
        cnt_x = 0;
        not_used = 0;
        while (i < n && cnt_v <= v) {
          if (s[i] == 'V') {
            cnt_v++;
          }
          if (s[i] == 'K') {
            if (cnt_k == k)
              not_used++;
            else
              cnt_k++;
          }
          if (s[i] == 'X') {
            if (cnt_x == x)
              not_used++;
            else
              cnt_x++;
          }
          i++;
        }
        if (v + 1 <= v_tot) {
          dp[k][v + 1][x][1] =
              min(dp[k][v + 1][x][1],
                  min(dp[k][v][x][0], dp[k][v][x][1]) + not_used);
        }
        i = 0;
        not_used = 0;
        cnt_v = 0;
        cnt_x = 0;
        cnt_k = 0;
        while (i < n && cnt_x <= x) {
          if (s[i] == 'X') {
            cnt_x++;
          }
          if (s[i] == 'K') {
            if (cnt_k == k)
              not_used++;
            else
              cnt_k++;
          }
          if (s[i] == 'V') {
            if (cnt_v == v)
              not_used++;
            else
              cnt_v++;
          }
          i++;
        }
        if (x + 1 <= x_tot) {
          dp[k][v][x + 1][0] =
              min(dp[k][v][x + 1][0],
                  min(dp[k][v][x][1], dp[k][v][x][0]) + not_used);
        }
      }
    }
  }
  cout << min(dp[k_tot][v_tot][x_tot][0], dp[k_tot][v_tot][x_tot][1]);
  return 0;
}
