To shrink a string "abbcccbfgh" by removing consecutive k characters till no removal can be done.
e.g. for k=3 output for the above string will be "afgh".
Please note that K and string both are dynamic i.e provided by the user. 

I wrote the below program but I couldn't complete it. Please help.

```
public class Test {

    public static void main(String[] args) {
        String str = "abbcccbfgh";
        int k = 3;

        String result = removeConsecutive(str, k);
        System.out.print("result is " + result);
    }

    private static String removeConsecutive(String str, int k) {
        String str1 = str + "";
        String res = "";
        int len = str.length();
        char c1 = 0, c2 = 0;
        int count = 0;
        for (int i = 0; i < len - 1; i++) {
            c1 = str.charAt(i);
            c2 = str.charAt(i + 1);

            if (c1 == c2) {
                count++;
            } else {

                res = res + String.valueOf(c1);
                count = 0;
            }
            if (count == k-1) {
                //remove String

            }
        }

        return res;
    }

```