Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.

Limak has a string s that consists of uppercase English letters. In one move he can swap two adjacent letters of the string. For example, he can transform a string "ABBC" into "BABC" or "ABCB" in one move.

Limak wants to obtain a string without a substring "VK" (i.e. there should be no letter 'V' immediately followed by letter 'K'). It can be easily proved that it's possible for any initial string s.

What is the minimum possible number of moves Limak can do?

Input

The first line of the input contains an integer n (1 ≤ n ≤ 75) — the length of the string.

The second line contains a string s, consisting of uppercase English letters. The length of the string is equal to n.

Output

Print one integer, denoting the minimum possible number of moves Limak can do, in order to obtain a string without a substring "VK".

Examples

Input

4
VKVK


Output

3


Input

5
BVVKV


Output

2


Input

7
VVKEVKK


Output

3


Input

20
VKVKVVVKVOVKVQKKKVVK


Output

8


Input

5
LIMAK


Output

0

Note

In the first sample, the initial string is "VKVK". The minimum possible number of moves is 3. One optimal sequence of moves is:

  1. Swap two last letters. The string becomes "VKKV".
  2. Swap first two letters. The string becomes "KVKV".
  3. Swap the second and the third letter. The string becomes "KKVV". Indeed, this string doesn't have a substring "VK".



In the second sample, there are two optimal sequences of moves. One is "BVVKV" → "VBVKV" → "VVBKV". The other is "BVVKV" → "BVKVV" → "BKVVV".

In the fifth sample, no swaps are necessary.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}

class Task {

    List<List<Integer>> g = new ArrayList<>();
    int[] p;
    //    static int MAX = 1000;
    boolean[] used;

    String s;
    int n;

    public void solve(Scanner in, PrintWriter out) {
        n = in.nextInt();
        s = in.next();
        int v = 0, k = 0, x = 0;
        List<Integer> vv = new ArrayList<>();
        List<Integer> kk = new ArrayList<>();
        List<Integer> xx = new ArrayList<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == 'V') {
                ++v;
                vv.add(i);
            } else if (c == 'K') {
                ++k;
                kk.add(i);
            } else {
                ++x;
                xx.add(i);
            }
        }

        long[][][][] dp = new long[v + 1][k + 1][x + 1][2];

        for (int i = 0; i <= v; i++) {
            for (int j = 0; j <= k; j++) {
                for (int l = 0; l <= x; l++) {
                    for (int m = 0; m < 2; m++) {
                        dp[i][j][l][m] = Long.MAX_VALUE;
                    }
                }
            }
        }
        dp[0][0][0][0] = 0;
        dp[0][0][0][1] = 0;

        for (int i = 0; i <= v; i++) {
            for (int j = 0; j <= k; j++) {
                for (int l = 0; l <= x; l++) {
                    for (int m = 0; m < 2; m++) {
                        if (dp[i][j][l][m] != Long.MAX_VALUE) {
                            if (i != v) {
                                dp[i + 1][j][l][1] = Math.min(dp[i + 1][j][l][1], dp[i][j][l][m] + Math.abs(i + j + l - ind(i,j,l,0)));
                            }
                            if (j != k && m == 0) {
                                dp[i][j + 1][l][0] = Math.min(dp[i][j + 1][l][0], dp[i][j][l][m] + Math.abs(i + j + l - ind(i,j,l,1)));
                            }
                            if (l != x) {
                                dp[i][j][l + 1][0] = Math.min(dp[i][j][l + 1][0], dp[i][j][l][m] + Math.abs(i + j + l - ind(i,j,l,2)));
                            }
                        }
                    }
                }
            }
        }


//        for (int i = 0; i <= v; i++) {
//            for (int j = 0; j <= k; j++) {
//                for (int l = 0; l <= x; l++) {
//                    System.out.println(i + " " + j + " " + x + " " + ind(i,j,l,0));
//                    System.out.println(i + " " + j + " " + x + " " + ind(i,j,l,1));
//                }
//            }
//        }
        System.out.println(Math.min(dp[v][k][x][0],dp[v][k][x][1]));
    }

    int ind(int i, int j, int l, int letter) {
        boolean[] used = new boolean[n];
        Arrays.fill(used, false);
        int counter = i + j + l;
        for (int k = 0; k < s.length(); k++) {
            char c = s.charAt(k);
            if (i > 0 && c == 'V') {
                used[k] = true;
                i--;
            }
            if (j > 0 && c == 'K') {
                used[k] = true;
                j--;
            }
            if (l > 0 && c != 'K' && c != 'V') {
                used[k] = true;
                l--;
            }
        }
        for (int k = 0; k < s.length(); k++) {
            if (used[k]) {
                continue;
            }
            if (s.charAt(k) == 'V' && letter == 0) {
                return counter;
            }
            if (s.charAt(k) == 'K' && letter == 1) {
                return counter;
            }
            if (s.charAt(k) != 'V' && s.charAt(k) != 'K' && letter == 2) {
                return counter;
            }
            counter++;
        }
        return -1;
    }

}


class Utils {

    public static int binarySearch(int[] a, int key) {
        int s = 0;
        int f = a.length;

        while (f > s) {
            int mid = (s + f) / 2;
            if (a[mid] > key) {
                f = mid - 1;
            } else if (a[mid] <= key) {
                s = mid + 1;
            }
        }
        return -1;
    }
}

class Pair<T, U> {
    public T a;
    public U b;

    public Pair(T a, U b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public boolean equals(Object obj) {
        Pair<T, U> p = (Pair<T, U>) obj;
        return p.a.equals(a) || p.a.equals(b);
    }

    @Override
    public int hashCode() {
        return 42;
    }
}


class Vect {
    public int a;
    public int b;

    public Vect(int a, int b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Vect vect = (Vect) o;

        if (a != vect.a) return false;
        return b == vect.b;

    }

    @Override
    public int hashCode() {
        int result = a;
        result = 31 * result + b;
        return result;
    }
}

class Triple<T, U, P> {
    public T a;
    public U b;
    public P c;

    public Triple(T a, U b, P c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
}


class Scanner {
    BufferedReader in;
    StringTokenizer tok;

    public Scanner(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
        tok = new StringTokenizer("");
    }

    private String tryReadNextLine() {
        try {
            return in.readLine();
        } catch (Exception e) {
            throw new InputMismatchException();
        }
    }

    public String nextToken() {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(next());
        }
        return tok.nextToken();
    }

    public String next() {
        String newLine = tryReadNextLine();
        if (newLine == null)
            throw new InputMismatchException();
        return newLine;
    }

    public int nextInt() {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() {
        return Long.parseLong(nextToken());
    }
}