#!/usr/bin/ruby a,b=gets.split.map(&:to_i).sort if b==0 gets;p $<.count{|e| x,y=e.split.map(&:to_i) x==0&&y==0 } elsif a==0 gets;p $<.count{|e| x,y=e.split.map(&:to_i) x%b==0&&y%b==0 } else raise g=a.gcd b a/=g b/=g gets;p $<.count{|e| x,y=e.split.map{|e|e.to_i.abs}.sort next if x%g!=0 || y%g!=0 x/=g y/=g y%(b-a)==0 && x%(b-a)==0 } end