import java.util.*;

public class PirateSolver {
	private List<Character> pirateList;
	private int noEnemies;
	
	public PirateSolver(String s) {
		pirateList = new ArrayList<Character>();
		int len = s.length();
		noEnemies = 0;
	
		for(int i=0; i<len; i++){
			int n = Character.getNumericValue(s.charAt(i));
			for(int j=0; j<n; j++){
				if(i%2==0){
					pirateList.add('E');
					noEnemies++;
				}
				else
					pirateList.add('F');
			}
		}
	}
	public List<Character> getCrew(){
		return pirateList;
	}
	
	public boolean throwOverBoardWithStep (int n){
		List<Character> pirateTest;
		pirateTest = new ArrayList<Character>();
		pirateTest.addAll(pirateList);
		int count = n-1;
		int noEne = noEnemies;
		while(noEne > 0){
			while(count < pirateTest.size()){
				if(pirateTest.get(count) == 'F')
					return true;
				pirateTest.remove(count);
				noEne--;
				if(noEne == 0)
					return false;
				count += n-1;
			}
			count -= pirateTest.size();
		}
		return false;
	}
	
	public int solution(){
		int step = 1;
		while (throwOverBoardWithStep(step)){
			step++;
		}
		return step;
	}
}

@@ -1087,10 +1087,206 @@
 tep;%0A%09%7D%0A
+%09%0A%09public static void main(String %5B%5D args) %7B%0A%09%09Scanner sc = new Scanner (System.in);%0A%09%09PirateSolver solver = new PirateSolver(sc.next());%0A%09%09sc.close();%0A%09%09System.out.println(solver.solution());%0A%09%7D%0A
 %7D%0A

Update PirateSolver.java