/* ACM ICPC Japan Domestic 99 Problem B: Unable Count by Naoyuki Tamura (tamura@kobe-u.ac.jp) */ import java.io.*; import java.util.*; public class B { static boolean dbg = false; static DataInputStream in = new DataInputStream(System.in); static int N; static int a; static int b; static void debug(String msg) { if (dbg) System.err.print(msg); } static boolean read() throws Exception { String line = null; debug("# Enter\n"); line = in.readLine(); StringTokenizer st = new StringTokenizer(line); N = Integer.parseInt(st.nextToken()); a = Integer.parseInt(st.nextToken()); b = Integer.parseInt(st.nextToken()); if (N == 0) return false; return true; } static int gcd(int x, int y) { int r = x % y; if (r == 0) return y; return gcd(y, r); } static int solve() { int g = gcd(a, b); int p = a / g; int q = b / g; int n = N / g; int c = 0; for (int i = 0; i < q; i++) { if (i*p > n) break; c += (n - i*p)/q + 1; } return c; } public static void main(String args[]) { if (args.length > 0) dbg = true; try { while (read()) { int c = (N+1) - solve(); System.out.println(c); } } catch (Exception e) { e.printStackTrace(); } } }