Use a variable to count the number of times it's HIGH. If the variable is less than 3, do your turning, if 3 then don't do turning. Something like this:
int turnCount =0; //put this before setup()
void loop(){
if (digitalRead(31) == HIGH && turnCount <3){
turnCount++; //increase the count
// your current turn code here
}
//You will need to reset turnCount to 0 at some time
//but you've not given any information on how and when you want this.
// probably you'll want to do it in the else part.
}