import Data.List
main = interact $ 
    (++"\n") . 
    show . 
    length . 
    nub . 
    uncurry intersect . 
    (\[_,s,_,t] -> (s,t)) . 
    map (map (read::String->Int) . words) . 
    lines


