problem with receive SMS

how can I do what you say ?

well there are some examples built into the IDE.
File -> Examples -> 02 Digital -> StateChangeDetection
will show you how to detect the rising and falling edges of pulses.

File -> Examples -> 02 Digital -> BlinkWithoutDelay
will show you how to use the millis timer. In your case you want to record the values given at the state change rather than using the timer to detect when to do something.