URL

Program

URL.PAS, URL.C, URL.CPP


Given the set of URLs (Uniform Resource Locator) the task is to count the number of the correct URLs corresponding to the following grammatical rules.
Explanation of some notational constructs:

xxx yyy - xxx should be followed by yyy
xxx | yyy - xxx or yyy should appear
"xxx" - xxx should appear explicitely
xxx - rule xxx should be applied
[ xxx ] - xxx is optional
*[ xxx ] - xxx is repeated zero or more times

httpurl        = "http://" hostname [ "/" hpath [ "?" search ]]
hpath          = hsegment *[ "/" hsegment ]
hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
search         = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
hostname       = *[ domainlabel "." ] domainlabel
domainlabel    = alpha | alpha *[ alphadigit | "-" ] alphadigit
uchar          = alpha | digit | safe | extra
alphadigit     = alpha | digit
alpha          = "a".."Z" | "A".."Z"
digit          = "0".."9"
safe           = "$" | "-" | "_" | "." | "+"
extra          = "!" | "*" | "'" | "(" | ")" | ","
 

Input Data

The file URL.IN consist of several test cases. In the first line of each test case, there is an integer N. Each of the following N lines contains an URL. End of input is terminated by end of file.

Output Data

For each test case the file URL.OUT contains a line with an integer which is the number of the correct URLs from the test case. The correct URL is the one which conforms to the gramatical rule "httpurl".

Sample Input and Output

Input:

4
http://www.rtk.si
http://www.nexor.com/public/rfc/rfcs/rfc1738.txt
http://av.yahoo.com/bin/query_uk?p=Tralala&z=2&hc=0&hs=0
http://vlado.mat.uni-lj.si/sreda/sreda.htm
3
http://www.3com.com
http://www-ai.ijs.si\slais\slais.html
http://www.ijs.si/cgi-bin/email?lang=[en]

Output:
4
0