using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC162B.Input;

namespace ABC162B
{
    static class Input
    {
        // Type Convert
        private static Func<string, T> C<T>()
        {
            Type t = typeof(T);
            if (t == typeof(string)) return _ => (T) (object) _;
            if (t == typeof(int)) return _ => (T) (object) int.Parse(_);
            if (t == typeof(long)) return _ => (T) (object) long.Parse(_);
            if (t == typeof(double)) return _ => (T) (object) double.Parse(_);
            if (t == typeof(char)) return _ => (T) (object) _[0];
            if (t == typeof(string[])) return _ => (T) (object) _.Split(' ');
            if (t == typeof(int[])) return _ => (T) (object) Cast<int>()(_);
            if (t == typeof(long[])) return _ => (T) (object) Cast<long>()(_);
            if (t == typeof(double[])) return _ => (T) (object) Cast<double>()(_);
            if (t == typeof(char[])) return _ => (T) (object) Cast<char>()(_);
            throw new NotSupportedException(t + "is not supported.");
            Func<string, T1[]> Cast<T1>() => _ => _.Split(' ').Select(C<T1>()).ToArray();
        }

        private static T C<T>(string s) => C<T>()(s);

        private static string String() => Console.ReadLine();
        private static string[] Split() => String().Split(' ');
        private static string[] String(long rowNumber) => new bool[rowNumber].Select(_ => String()).ToArray();

        private static (T1, T2) In<T1, T2>(string[] v) => (C<T1>(v[0]), C<T2>(v[1]));
        private static (T1, T2, T3) In<T1, T2, T3>(string[] v) => (C<T1>(v[0]), C<T2>(v[1]), C<T3>(v[2]));

        private static (T1, T2, T3, T4) In<T1, T2, T3, T4>(string[] v) =>
            (C<T1>(v[0]), C<T2>(v[1]), C<T3>(v[2]), C<T4>(v[3]));

        private static (T1, T2, T3, T4, T5) In<T1, T2, T3, T4, T5>(string[] v) =>
            (C<T1>(v[0]), C<T2>(v[1]), C<T3>(v[2]), C<T4>(v[3]), C<T5>(v[4]));

        private static (T1, T2, T3, T4, T5, T6) In<T1, T2, T3, T4, T5, T6>(string[] v) =>
            (C<T1>(v[0]), C<T2>(v[1]), C<T3>(v[2]), C<T4>(v[3]), C<T5>(v[4]), C<T6>(v[5]));

        /* いくつかの変数を受け取る */
        public static void Cin<T>(out T a) => a = C<T>(String());
        public static void Cin<T1, T2>(out T1 a, out T2 b) => (a, b) = In<T1, T2>(Split());

        public static void Cin<T1, T2, T3>(out T1 a, out T2 b, out T3 c) => (a, b, c) = In<T1, T2, T3>(Split());

        public static void Cin<T1, T2, T3, T4>(out T1 a, out T2 b, out T3 c, out T4 d) =>
            (a, b, c, d) = In<T1, T2, T3, T4>(Split());

        public static void Cin<T1, T2, T3, T4, T5>(out T1 a, out T2 b, out T3 c, out T4 d, out T5 e) =>
            (a, b, c, d, e) = In<T1, T2, T3, T4, T5>(Split());

        public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a, out T2 b, out T3 c, out T4 d, out T5 e, out T6 f) =>
            (a, b, c, d, e, f) = In<T1, T2, T3, T4, T5, T6>(Split());

        /* 1行に書かれた配列を受け取る */
        public static void Cin<T>(out T[] a) => a = C<T[]>(String());

        /* n行に書かれたいくつかの配列を受け取る */
        public static void Cin<T>(long n, out T[] l) => l = String(n).Select(C<T>()).ToArray();

        public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2)
        {
            (l1, l2) = (new T1[n], new T2[n]);
            for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i]);
        }

        public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2, out T3[] l3)
        {
            (l1, l2, l3) = (new T1[n], new T2[n], new T3[n]);
            for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i]);
        }

        public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2, out T3[] l3, out T4[] l4)
        {
            (l1, l2, l3, l4) = (new T1[n], new T2[n], new T3[n], new T4[n]);
            for (int i = 0; i < n; i++) Cin(out l1[i], out l2[i], out l3[i], out l4[i]);
        }

        /* T型の行列を受け取る */
        public static void Cin<T>(long h, out T[][] map) => map = String(h).Select(C<T[]>()).ToArray();
    }

    class Program
    {
        public static void Main(string[] args)
        {
            StreamWriter streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            new Solver().Solve();
            Console.Out.Flush();
        }

        public static void Debug()
        {
            new Solver().Solve();
        }
    }

    class Solver
    {
        public void Solve()
        {
            Cin(out int n);
            List<long> ans = new List<long>();
            for (int i = 1; i <= n; i++)
            {
                if (i % 3 != 0 && i % 5 != 0) ans.Add(i);
            }

            Console.WriteLine(ans.Sum());
        }
    }
}

Measured memory_bytes: 41160