#include "bits/stdc++.h" // Begin {{{ using namespace std; #define all(x) x.begin(), x.end() #define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i) #define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i) #define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i) #define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__) using i64 = int_fast64_t; using pii = pair; template using MaxHeap = priority_queue; template using MinHeap = priority_queue, greater<>>; template inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } template inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } inline i64 sigma(i64 n) { return n * (1 + n) >> 1; } inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; } constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int MOD = int(1e9) + 7; #ifndef DEBUG #define dump(...) #endif inline void input() {} template inline void input(Head&& head, Tail&&... tail) { cin >> head; input(forward(tail)...); } inline void outs() { cout << "\n"; } template inline void outs(Head&& head, Tail&&... tail) { cout << head << (sizeof...(tail) ? " " : ""); outs(forward(tail)...); } template inline void outs(vector &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; } template inline void outs(vector> &df) { for (auto &vec : df) outs(vec); } inline void outl() { cout << "\n"; } template inline void outl(Head&& head, Tail&&... tail) { cout << head << (sizeof...(tail) ? "\n" : ""); outl(forward(tail)...); } template inline void outl(vector &vec) { for (auto &e : vec) cout << e << "\n"; } inline void outn() {} template inline void outn(Head&& head, Tail&&... tail) { cout << head; outn(forward(tail)...); } template inline void outn(vector &vec) { for (auto &e : vec) cout << e; } template inline vector make_v(const T &initvalue, size_t sz) { return vector(sz, initvalue); } template inline auto make_v(const T &initvalue, size_t sz, Args... args) { return vector(initvalue, args...))>(sz, make_v(initvalue, args...)); } // }}} End i64 lcm(i64 a, i64 b) { return a / __gcd(a, b) * b; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); var(i64, t, a, b); t--; i64 a_cnt = t / a + 1; i64 b_cnt = t / b + 1; i64 a_b_cnt = t / lcm(a, b) + 1; outl(a_cnt + b_cnt - a_b_cnt); return 0; }