private int startWith(int n, ArrayList<Candy> t0, ArrayList<Candy> t1){

		int cnt = 0;
		int curr = 0;
		int last = n;
		
		while(true){
			curr = cnt;
			int chosen = -1;
			if(last == 0){
				for(int i=0;i<t0.size();i++){
					if(x>=t0.get(i).h){
						chosen = i;
						break;
					}
				}
				if(chosen >= 0){
					last = 1;
					cnt++;
					x+=t0.get(chosen).m;
					t0.remove(chosen);
				}
			} else {
				for(int i=0;i<t1.size();i++){
					if(x>=t1.get(i).h){
						chosen = i;
						break;
					}
				}
				if(chosen >= 0){
					last = 0;
					cnt++;
					x+=t1.get(chosen).m;
					t1.remove(chosen);
				}
			}
			if(curr == cnt) break;
		}	
		
		return cnt;
	}