|The first mall of the kingdom is about to be inaugurated in a few days. The king wants to make sure that the mall is highly secured.|
The mall has N floors, numbered 1 to N. Each floor has stations which allow people to enter or leave the floor to which the station belongs. All escalators in the mall begin and end at stations of adjacent floors. To make movement of people easier, super-escalators connect stations in floor 1 to stations in floor N. Each escalator or super-escalator can be used to go upwards as well as downwards. If the i-th floor has Ki stations then the stations are numbered from 1 to Ki. The escalators and super-escalators are constructed in such a way that a person can reach any station from any other station using them.
The king wants to have as many guards in the mall as possible to make it secure. Guards can only be placed at stations and at most 1 guard can be placed at a station. Moreover, the people of the kingdom become panicky if they see more than one guard at a time. Hence, there should be no such escalator (or super-escalator) such that guards are placed at both its end stations.
You are given a String escDescription which when concatenated represents a comma (',') separated list of escalators and super-escalators. Every escalator (or super-escalator) is of the form "A B C". If C is less than N, the String represents an escalator from station A of floor C, to station B of floor C+1. If C is equal to N, then the String represents a super-escalator from station A of floor C (= N), to station B of floor 1. Help the king by returning the maximum number of guards he can place in the mall.
|-||N will be between 10 and 50, inclusive.|
|-||The total number of stations in the mall will not exceed 100.|
|-||escDescription will contain between 1 and 50 elements, inclusive.|
|-||Each element of escDescription will contain between 1 and 50 characters, inclusive.|
|-||The concatenation of the elements of escDescription will be a comma separated list of escalators and super-escalators.|
|-||Each escalator and super-escalator will be given as "A B C" (quotes for clarity), where A, B and C are positive integers with no leading zeros.|
|-||In each escalator and super-escalator description, A will be a valid number of station located on floor C.|
|-||In each escalator and super-escalator description, B will be a valid number of station located on floor C + 1 (or on floor 1, if C = N).|
|-||In each escalator and super-escalator description, C will be between 1 and N, inclusive.|
|-||Each floor will have at least 1 station.|
|-||The stations on each floor will be numbered from 1 to K, inclusive, where K is the total number of stations on this floor.|
|-||Each pair of stations will be connected with at most one escalator or super-escalator.|
|-||It will be possible to reach any station from any other station using escalators and super-escalators.|