import java.io.*; import java.math.*; import java.util.*; public class Class { static BigInteger one = BigInteger.ONE; static BigInteger zero = BigInteger.ZERO; static BigInteger two = BigInteger.valueOf(2); static BigInteger sum (BigInteger a0, BigInteger n) { BigInteger d = a0.multiply(n.subtract(one)); BigInteger num = d.add(a0.multiply(two)); BigInteger ret = num.multiply(n); return ret.divide(two); } public static void main(String[] args) throws IOException { //PrintWriter pw = new PrintWriter(new File("output.txt")); //Scanner sc = new Scanner (new File("input.txt")); Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); BigInteger n = sc.nextBigInteger(); BigInteger a = sc.nextBigInteger(); BigInteger b = sc.nextBigInteger(); BigInteger modulo = BigInteger.valueOf(1000000007); BigInteger c = a.multiply(b); BigInteger n1 = n.divide(a).subtract(n.mod(a) == zero ? one : zero); BigInteger n2 = n.divide(b).subtract(n.mod(b) == zero ? one : zero); BigInteger n3 = n.divide(c).subtract(n.mod(c) == zero ? one : zero); BigInteger sum1 = sum(a, n1); BigInteger sum2 = sum(b, n2); BigInteger sum3 = sum(c, n3); BigInteger ans = sum1.add(sum2).subtract(sum3); pw.println(ans.mod(modulo)); sc.close(); pw.flush(); return; } }