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