Assistance in diploma. Question programming the Arduino mega

This is result:

#include <AFMotor.h>  // ?????????? ?????????? ??? ?????? ? ?????? 
#include <Servo.h> 
#include <Arduino.h>
// ?????????? ?????? ? ?????????? M1, M2, M3, M4
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
void setup(){
	// ?????? ???????????? ???????? ???????? ??????? (?????? ?????? PWM) 
	motor1.setSpeed(255);
	motor1.run(RELEASE);
	motor2.setSpeed(255);
	motor2.run(RELEASE);
	motor3.setSpeed(255);
	motor3.run(RELEASE);
	motor4.setSpeed(255);
	motor4.run(RELEASE);
        int turnCount=0;
        int turnCount1=0;
}
int turnCount1=0;
int turnCount=0;
void loop(){
  
            digitalRead(31);
  
  if (digitalRead(31) == HIGH && turnCount <5)
  { 
        turnCount++; 
        motor1.run(FORWARD); // ?????? ???????? ??????
	motor2.run(FORWARD);
	motor3.run(FORWARD);
	motor4.run(FORWARD);
        motor1.setSpeed(150); // ?????? ???????? ????????
	motor2.setSpeed(150); 
	motor3.setSpeed(150); 
	motor4.setSpeed(150); 
	delay(350);

         // ????????????? ?????????
	/* ????? ?? ??????????? ????? ??????????? ??????????? ???????? ??????????.
	????? ???? ????????? ?????????? ???????.*/

	motor1.run(RELEASE); 
	motor2.run(RELEASE);
	motor3.run(RELEASE);
	motor4.run(RELEASE);
	delay(1000);

        motor1.run(BACKWARD);  // ?????? ???????? ?????
	motor2.run(BACKWARD);
	motor3.run(BACKWARD);
	motor4.run(BACKWARD);
	motor1.setSpeed(150);  // ?????? ???????? ???????? 
	motor2.setSpeed(150); 
	motor3.setSpeed(150); 
	motor4.setSpeed(150); 
	delay(350);
  
        motor1.run(RELEASE);
	motor2.run(RELEASE);
	motor3.run(RELEASE);
	motor4.run(RELEASE);
	delay(1000);
// ?? ???? 
        motor1.run(FORWARD); // ?????? ???????? ??????
	motor4.run(FORWARD);
	motor1.setSpeed(140); // ?????? ???????? ????????
	motor4.setSpeed(140); 
	delay(350);

	// ????????????? ?????????
	/* ????? ?? ??????????? ????? ??????????? ??????????? ???????? ??????????.
	????? ???? ????????? ?????????? ???????.*/

	motor1.run(RELEASE); 
	motor2.run(RELEASE);
	motor3.run(RELEASE);
	motor4.run(RELEASE);
	delay(5000);
  }
if (digitalRead(31) == LOW && turnCount1 <7)
{
turnCount1++;
// ?? ???? 
        motor1.run(FORWARD); // ?????? ???????? ??????
	motor4.run(FORWARD);
	motor1.setSpeed(140); // ?????? ???????? ????????
	motor4.setSpeed(140); 
	delay(350);

	// ????????????? ?????????
	/* ????? ?? ??????????? ????? ??????????? ??????????? ???????? ??????????.
	????? ???? ????????? ?????????? ???????.*/

	motor1.run(RELEASE); 
	motor2.run(RELEASE);
	motor3.run(RELEASE);
	motor4.run(RELEASE);
	delay(5000);
}
}