import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int box = sc.nextInt(); int count = sc.nextInt(); ArrayList boxlist = new ArrayList(); for(int i=0;itotal&&boxlist.size()>k;k++){ total += boxlist.get(k); if(box>total){ result++; }else{ break; } } System.out.println(result); }// mainmethod } // class