# your code goes here
DATA.read.split.each{|line|
puts line
m = line.match(
/
^[a-zA-Z0-9]{,100}
(?:
[a-zA-Z0-9]{1,100}
| <a>[a-zA-Z0-9]{,100}(?:<b>[a-zA-Z0-9]{,100}<\/b>[a-zA-Z0-9]{,100})?<\/a>
| <b>[a-zA-Z0-9]{,100}<\/b>
)*$
/x)
puts (m ? 1 : 0)
}
__END__
<a>ruby<b>php</b>python</a><a><b></b></a><a></a>
<a>ruby<b>php</b>python</a><a></b></a><a></a>
<a>ruby<b>php</b>python</a><a><b></a><a></a>
<a>ruby<b>php</b>python</a><a><b></b></a><a>
vvvc<a>ruby<b>php</b>python</a><a><b></b></a><a></a>
IyB5b3VyIGNvZGUgZ29lcyBoZXJlCkRBVEEucmVhZC5zcGxpdC5lYWNoe3xsaW5lfAogIHB1dHMgbGluZQogIG0gPSBsaW5lLm1hdGNoKAogICAgLwogICAgICBeW2EtekEtWjAtOV17LDEwMH0KICAgICAgKD86CiAgICAgICAgICBbYS16QS1aMC05XXsxLDEwMH0KICAgICAgICB8IDxhPlthLXpBLVowLTldeywxMDB9KD86PGI+W2EtekEtWjAtOV17LDEwMH08XC9iPlthLXpBLVowLTldeywxMDB9KT88XC9hPgogICAgICAgIHwgPGI+W2EtekEtWjAtOV17LDEwMH08XC9iPgogICAgICApKiQKICAgIC94KQogIHB1dHMgKG0gPyAxIDogMCkKfQoKX19FTkRfXwo8YT5ydWJ5PGI+cGhwPC9iPnB5dGhvbjwvYT48YT48Yj48L2I+PC9hPjxhPjwvYT4KPGE+cnVieTxiPnBocDwvYj5weXRob248L2E+PGE+PC9iPjwvYT48YT48L2E+CjxhPnJ1Ynk8Yj5waHA8L2I+cHl0aG9uPC9hPjxhPjxiPjwvYT48YT48L2E+CjxhPnJ1Ynk8Yj5waHA8L2I+cHl0aG9uPC9hPjxhPjxiPjwvYj48L2E+PGE+CnZ2dmM8YT5ydWJ5PGI+cGhwPC9iPnB5dGhvbjwvYT48YT48Yj48L2I+PC9hPjxhPjwvYT4K