#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long maxn = 70 + 10, N = 2e6 + 90, SQ = 300, base = 1999,
                mod = 1e9 + 7, INF = 1e9 + 1, lg = 25;
const long double eps = 1e-4;
long long n, dp[maxn][maxn][maxn][2], sz1, sz2, sz3;
string s;
inline void pre() {
  for (long long i = 0; i < n; ++i) {
    if (s[i] == 'V') {
      sz1++;
    }
    if (s[i] == 'K') {
      sz2++;
    }
    if (s[i] != 'V' && s[i] != 'K') {
      s[i] = 'X';
      sz3++;
    }
  }
  for (long long i = 0; i <= n; ++i) {
    for (long long j = 0; j <= n; ++j) {
      for (long long k = 0; k <= n; ++k) {
        dp[i][j][k][0] = dp[i][j][k][1] = INF;
      }
    }
  }
  dp[0][0][0][0] = 0;
}
inline void find_first(long long &id1, long long &id2, long long &id3,
                       long long i, long long j, long long k) {
  long long c1 = 0, c2 = 0, c3 = 0;
  string tmp = "";
  for (long long id = 0; id < n; ++id) {
    if (s[id] == 'V') {
      c1++;
      if (c1 > i) {
        tmp += s[id];
      }
    }
    if (s[id] == 'K') {
      c2++;
      if (c2 > j) {
        tmp += s[id];
      }
    }
    if (s[id] == 'X') {
      c3++;
      if (c3 > k) {
        tmp += s[id];
      }
    }
  }
  for (long long id = 0; id < (long long)tmp.size(); ++id) {
    if (tmp[id] == 'V' && id1 == -1) {
      id1 = id;
    }
    if (tmp[id] == 'K' && id2 == -1) {
      id2 = id;
    }
    if (tmp[id] == 'X' && id3 == -1) {
      id3 = id;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s;
  pre();
  for (long long i = 0; i <= sz1; ++i) {
    for (long long j = 0; j <= sz2; ++j) {
      for (long long k = 0; k <= sz3; ++k) {
        long long id1 = -1, id2 = -1, id3 = -1;
        find_first(id1, id2, id3, i, j, k);
        if (id1 != -1) {
          dp[i + 1][j][k][1] = min(dp[i + 1][j][k][1], dp[i][j][k][0] + id1);
          dp[i + 1][j][k][1] = min(dp[i + 1][j][k][1], dp[i][j][k][1] + id1);
        }
        if (id2 != -1) {
          dp[i][j + 1][k][0] = min(dp[i][j + 1][k][0], dp[i][j][k][0] + id2);
        }
        if (id3 != -1) {
          dp[i][j][k + 1][0] = min(dp[i][j][k + 1][0], dp[i][j][k][0] + id3);
          dp[i][j][k + 1][0] = min(dp[i][j][k + 1][0], dp[i][j][k][1] + id3);
        }
      }
    }
  }
  cout << min(dp[sz1][sz2][sz3][0], dp[sz1][sz2][sz3][1]) << '\n';
}
