Count and use the same time

thank you for read

Edit ****

int ledPin = 40;                // LED connected to digital pin 13
int ledValue = LOW;             // previous value of the LED
long ledStartTime = 0;          // will store last time LED was updated
long ledBlinkInterval = 3000;   // interval at which to blink (milliseconds)

int buttonPin = 22;              // an active-high momentary pushbutton on pin 2
int buttonValue = HIGH;         // the current state of the button
long buttonPressTime = 0;       // will store the time that the button was pressed


void setup()
{
 pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
 // Check to see if the button is pressed.  If so, mark the time.  When the
 // button is released, calculate how long it was pressed, and make the led
 // blink at the same rate.
 buttonValue = digitalRead(buttonPin);

 // button press
 if (buttonValue==LOW && buttonPressTime==0) {
   buttonPressTime = millis();  // capture the time of the press
 }

 // button release
 if (buttonValue==HIGH && buttonPressTime!=0) {
   ledBlinkInterval = millis() - buttonPressTime;  // set the new flash interval
   buttonPressTime = 0;                            // clear the button press time
 }

 // check to see if it's time to blink the LED; that is, is the difference
 // between the current time and last time we blinked the LED bigger than
 // the interval at which we want to blink the LED.
 if (millis() - ledStartTime > ledBlinkInterval) {
   ledStartTime = millis();   // remember the last time we blinked the LED

   // if the LED is off turn it on and vice-versa.
   if (ledValue == LOW)
     ledValue = HIGH;
   else
     ledValue = LOW;

   digitalWrite(ledPin, ledValue);
 }
}

i was missing a part, sorry...yes compile and works, basically This code places intervals of time to blink, and I need is, if I press a button X number of times the LED stays lit X amount of time and turns off after the time expires