#include <bits/stdc++.h>
using namespace std;
const int N = 80;
const int inf = 0x3f3f3f3f;
int n, dp[N][N][N][3];
vector<int> V[3];
char s[N];
int a[3];
int cost(int x, int y, int z, int p) {
  int ret = 0;
  int g = 0;
  if (p == 0) {
    g = V[0][x];
  } else if (p == 1) {
    g = V[1][y];
  } else {
    g = V[2][z];
  }
  int h = g;
  for (int i = 0; i < x; i++) {
    if (V[0][i] > h) {
      g++;
    }
  }
  for (int i = 0; i < y; i++) {
    if (V[1][i] > h) {
      g++;
    }
  }
  for (int i = 0; i < z; i++) {
    if (V[2][i] > h) {
      g++;
    }
  }
  return g - x - y - z - 1;
}
inline void Min(int &a, int b) {
  if (a > b) a = b;
}
int main() {
  int x;
  while (~scanf("%d", &n)) {
    scanf("%s", s);
    for (int i = 0; i < 3; i++) {
      V[i].clear();
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == 'V') {
        x = 0;
      } else if (s[i] == 'K') {
        x = 1;
      } else {
        x = 2;
      }
      V[x].push_back(i + 1);
    }
    memset(dp, 0x3f, sizeof(dp));
    for (int i = 0; i < 3; i++) {
      a[i] = V[i].size();
    }
    dp[0][0][0][2] = 0;
    for (int i = 0; i <= a[0]; i++) {
      for (int j = 0; j <= a[1]; j++) {
        for (int k = 0; k <= a[2]; k++) {
          for (int l = 0; l < 3; l++) {
            if (dp[i][j][k][l] == inf) continue;
            if (i < a[0]) {
              Min(dp[i + 1][j][k][0], dp[i][j][k][l] + cost(i, j, k, 0));
            }
            if (j < a[1] && l != 0) {
              Min(dp[i][j + 1][k][1], dp[i][j][k][l] + cost(i, j, k, 1));
            }
            if (k < a[2]) {
              Min(dp[i][j][k + 1][2], dp[i][j][k][l] + cost(i, j, k, 2));
            }
          }
        }
      }
    }
    printf("%d\n", min(dp[a[0]][a[1]][a[2]][0],
                       min(dp[a[0]][a[1]][a[2]][1], dp[a[0]][a[1]][a[2]][2])));
  }
  return 0;
}
