#include<bits/stdc++.h>
int findKRotation(vector<int> &arr){
    int n = arr.size();
        int low=0;
        int high=n-1;
        int mini=INT_MAX;
        int index=-1;
        while(low<=high){
            int mid = (low+high)/2;
            if(arr[low]<=arr[high]){
                if (arr[low] < mini) {
                    index = low;
                    mini = arr[low];
                }
                break;
            }
            if(arr[low]<=arr[mid]){
                if (arr[low] < mini) {
                    index = low;
                    mini = arr[low];
                }
                low=mid+1;
            }
            else{
                if (arr[mid] < mini) {
                    index = mid;
                    mini = arr[mid];
                }
                high=mid-1;
            }
        }
        return index;
}