def stored_cookie_messages_count(storage, response):
<EOL>cookie = response.cookies.get(storage.cookie_name)<EOL>if not cookie or cookie['<STR_LIT>'] == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>data = storage._decode(cookie.value)<EOL>if not data:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>if data[-<NUM_LIT:1>] == CookieStorage.not_finished:<EOL><INDENT>data.pop()<EOL><DEDENT>return len(data)<EOL>
Return an integer containing the number of messages stored.