public static void main(String[] args) { int n,k; Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); k = scanner.nextInt(); String end = scanner.nextLine(); String line = scanner.nextLine(); int[] consume = new int[n]; char[] arr = line.toCharArray(); for(int i=0;i consume[i] = arr[i] - 'a' + 1; } int now = 0; int energy = k; while(now+1 int x = consume[now+1]-consume[now]; if(x>0){ energy -= x; }else{ energy += Math.abs(x); } if(energy System.out.println(-1); return; } now++; } System.out.println(energy); }