PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000004. Tổng không chứa bội (FizzBuzz Sum Hard)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng không chứa bội (FizzBuzz Sum Hard)

FizzBuzz Sum Hard

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Consider all integers from 11 through NN. Exclude numbers divisible by at least one of AA or BB. Compute the sum of all remaining integers; the sum of an empty set is zero.

Input

One line with N,A,BN,A,B.

Output

Print the required sum.

Subtasks

  • Subtask 1 (20 points): 1≤N,A,B≤1001 \le N,A,B \le 100
  • Subtask 2 (30 points): 1≤N,A,B≤1051 \le N,A,B \le 10^{5}
  • Subtask 3 (50 points): 1≤N,A,B≤1091 \le N,A,B \le 10^{9}

Examples

Input

10 3 5

Output

22

Explanation

The retained numbers are 1,2,4,7,81,2,4,7,8. Their sum is 2222.