local function lltonumber(str) local ret = 0LL for i = 1, #str do ret = ret * 10LL ret = ret + tonumber(str:sub(i, i)) end return ret end local function getgcd(x, y) while 0 < x do x, y = y % x, x end return y end local s = io.read() local st, sa, sb = s:match("(%d+) (%d+) (%d+)") local t, a, b = lltonumber(st), lltonumber(sa), lltonumber(sb) local ra = (t - 1LL) / a + 1 local rb = (t - 1LL) / b + 1 local gcd = getgcd(a, b) local rc = ((t - 1) / a) / (b / gcd) + 1 local str = tostring(ra + rb - rc):gsub("LL", "") print(str)