Fundamentals - Java - LadyBugs

Здравеите, имам проблем със задачата лади бугс , решението ми е едно към едно с поправката на упражнението но получавам постоянен runtime error.

 

package SoftUniArrays;

import java.util.Scanner;

public class ladyBigs {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int fieldsize = Integer.parseInt(scan.nextLine());
        String bugs = scan.nextLine();
        String[] ladybugs = bugs.split(" ");

        int[] arrayOfLadyBugs = new int[ladybugs.length];
        for (int i = 0; i < ladybugs.length; i++) {
            arrayOfLadyBugs[i] = Integer.parseInt(ladybugs[i]);
        }

        int[] arrayField = new int[fieldsize];

        for (int i = 0; i < ladybugs.length; i++) {
            if (arrayOfLadyBugs[i]>=0 && arrayOfLadyBugs[i] < fieldsize) {
                arrayField[arrayOfLadyBugs[i]] = 1;
            }


        }


        int move = 0;
        int indexToMove = 0;
        int counter = 0;

        String theInstructions = scan.nextLine();
        while (!theInstructions.equals("end")) {
            String[] instructions = theInstructions.split(" ");
            if (instructions[1].equals("right")) {
                move = Integer.parseInt(instructions[2]);
                indexToMove = Integer.parseInt(instructions[0]);

                    arrayField[indexToMove] = 0;
                    counter = indexToMove + move;

                    while (counter < arrayField.length && arrayField[counter] != 0) {
                        counter += move;
                    }
                    if (counter < arrayField.length) {
                        arrayField[counter] = 1;
                    }

            }else if (instructions[1].equals("left")) {

                move = Integer.parseInt(instructions[2]);
                indexToMove = Integer.parseInt(instructions[0]);

                    arrayField[indexToMove] = 0;
                    counter = indexToMove - move;
                    while (counter >= 0 && arrayField[counter] != 0) {
                        counter -= move;
                    }
                    if (counter >= 0) {
                        arrayField[counter] = 1;
                    }

            }
            theInstructions = scan.nextLine();
        }

        for (int i = 0; i < fieldsize; i++) {
            System.out.print(arrayField[i]+" ");
        }
    }
}