#include <bits/stdc++.h>
int n;
char str[(80)];
int dp[(80)][(80)][(80)][2];
int cnt_v[(80)], cnt_k[(80)], cnt_x[(80)];
std::vector<int> vec_v, vec_k, vec_x;
int main() {
  scanf("%d%s", &n, str + 1);
  for (int i = 1; i <= n; ++i) {
    cnt_v[i] = cnt_v[i - 1];
    cnt_k[i] = cnt_k[i - 1];
    cnt_x[i] = cnt_x[i - 1];
    switch (str[i]) {
      case 'V':
        vec_v.push_back(i);
        ++cnt_v[i];
        break;
      case 'K':
        vec_k.push_back(i);
        ++cnt_k[i];
        break;
      default:
        vec_x.push_back(i);
        ++cnt_x[i];
    }
  }
  memset(dp, 0x7f, sizeof(dp));
  int A = (int)vec_v.size(), B = (int)vec_k.size(), C = (int)vec_x.size();
  dp[0][0][0][0] = 0;
  for (int i = 0; i <= A; ++i) {
    for (int j = 0; j <= B; ++j) {
      for (int k = 0; k <= C; ++k) {
        if (!i && !j && !k) continue;
        if (i) {
          int posV = vec_v[i - 1];
          int costV =
              std::max(0, cnt_k[posV] - j) + std::max(0, cnt_x[posV] - k);
          dp[i][j][k][1] =
              std::min(dp[i - 1][j][k][0], dp[i - 1][j][k][1]) + costV;
        }
        if (j) {
          int posK = vec_k[j - 1];
          int costK =
              std::max(0, cnt_v[posK] - i) + std::max(0, cnt_x[posK] - k);
          dp[i][j][k][0] = dp[i][j - 1][k][0] + costK;
        }
        if (k) {
          int posX = vec_x[k - 1];
          int costX =
              std::max(0, cnt_v[posX] - i) + std::max(0, cnt_k[posX] - j);
          dp[i][j][k][0] = std::min(
              dp[i][j][k][0],
              std::min(dp[i][j][k - 1][0] + costX, dp[i][j][k - 1][1] + costX));
        }
      }
    }
  }
  printf("%d\n", std::min(dp[A][B][C][0], dp[A][B][C][1]));
  return 0;
}
