while true
    n, a, b = gets.chomp.split.map(&:to_i)
    break if [n, a, b] == [0, 0, 0]
    count, m, h = n / a, 1, {0=>true}
    while b * m <= n
        r = (b * m) % a
        break if h[r]
        h[r] = true
        count += (n % a >= r) ? n / a + 1 : n / a
        count -= b * m / a
        m += 1
    end
    puts n - count
end
