#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU def gs(); gets.chomp; end def gi(); gets.to_i; end def gss(); gets.chomp.split; end def gis(); gss.map(&:to_i); end P, Q = gis N = gi d = P == Q ? P : (P - Q).abs c = 0 N.times do x, y = gis.map(&:abs) if P == 0 && Q == 0 c += 1 if x == 0 && y == 0 else c += 1 if x % d == 0 && y % d == 0 end end p c