#! 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 # 解説読後 # http://yukicoder.me/problems/849/editorial P, Q = gis N = gi d = P * Q == 0 ? P + Q : P.gcd(Q) if P == 1 || Q == 1 || d == 1 puts N exit end c = 0 N.times do x, y = gis.map(&:abs) c += 1 if x % d == 0 && y % d == 0 end p c