import java.util.*; public class No5 { public static void main (String[] args){ int L, N; Scanner sc = new Scanner(System.in); L = sc.nextInt(); N = sc.nextInt(); int[] W = new int[N + 1]; int i; for(i = 0 ; i < N ; i++){ W[i] = sc.nextInt(); } L -= W[i]; while(L >= 0){ i--; L -= W[i]; } System.out.println(N - i - 1); } }