Scanf.scanf "%d" (fun n ->
    let n3 = n / 3 in
    let n5 = n / 5 in
    let n15 = n / 15 in
    Printf.printf "%d\n" @@
    n * (n + 1) / 2 - 3 * n3 * (n3 + 1) / 2
                    - 5 * n5 * (n5 + 1) / 2
                    + 15 * n15 * (n15 + 1) / 2
)