Get SMS postion on Siemens MC35i

hello all
I'm working with a modem reading sms and is working very well.I need to prevent a possible problem in my code that is expecting to read sms in location from 0-9 in modem memory.In case modem is offline and someone seend sms to it I will lose control of reading sms from it because I dont know any more on what position the sms memory are.
There is a AT command that list me all the sms on the memory but give me lots of data that will certain overload the Serial buffer if I try to read it at once.The location is just after "CMGL: ", for example "+CMGL: 1,"REC READ","+351xxxxxxxx",,"12/03/15,12:34:17+00"
123" says there is a message on first location and so on
All I need is the final position like 11 on this case above to then do a if cycle to clean down all sms until position 1
Can someone give me a hint how can I just filter this and discard all the rest

at+cmgl="all"

+CMGL: 1,"REC READ","+351xxxxxxxx",,"12/03/15,12:34:17+00"
123
+CMGL: 2,"REC READ","+351xxxxxxxx",,"12/03/15,12:43:10+00"
123
+CMGL: 3,"REC READ","+351xxxxxxxx",,"12/03/22,23:25:43+00"
123

+CMGL: 4,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:41:11+00"
1
+CMGL: 5,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:41:50+00"
A
+CMGL: 6,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:42:06+00"
B
+CMGL: 7,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:42:25+00"
M

+CMGL: 8,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:42:41+00"
Mj
+CMGL: 9,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:42:58+00"
Jg
+CMGL: 10,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:43:10+00"
6
+CMGL: 11,"REC UNREAD","+351xxxxxxxx",,"12/03/23,17:43:37+00"
5

Thanks for all

There is a AT command that list me all the sms on the memory but give me lots of data that will certain overload the Serial buffer if I try to read it at once

The command sent to the modem will cause it to send the data to the Arduino, which will store it in the serial buffer, until you read it.

The key, then, is to not diddle around doing other stuff. Read the data sent back by the modem faster than it sends it (which is not hard to do) and the buffer will not overflow.

There are non-printing characters in the data sent back. There are also printable characters that you can key on. Create an array large enough to hold an entire message (typically 160 characters max) plus the header.

When the character read from the serial port is a +, collect the next 4 characters in two arrays - the main one and a command array. If, after 4 more characters, the command array contains "CMGL:, you have the start of a new message. Reset the main array, and read until you get the end of the header, then read more until you get the end of the message.

When there is no more data to read, the array contains the last header and message. Parse the data.