Kattis Challenge "Server"

Problem

My solution

 1import java.util.Scanner;
 2
 3public class KattisC {
 4
 5    public static void main(String[] args) {
 6
 7        Scanner sc = new Scanner(System.in);
 8
 9        while (sc.hasNext()) {
10
11            String[] nT = new String[2];
12
13            nT = sc.nextLine().split(" ");
14
15            int n = Integer.parseInt(nT[0]);
16            int T = Integer.parseInt(nT[1]);
17
18            int counter = 0;
19            int sum = 0;
20
21            String[] posInts = new String[30];
22
23            posInts = sc.nextLine().split(" ");
24
25            while (counter < n) {
26
27                sum += Integer.parseInt(posInts[counter]);
28
29                if (sum > T) {
30                   
31                    break;
32                }
33                counter++;
34
35            }
36
37            System.out.println(counter);
38        }
39    }
40}