#include <bits/stdc++.h>
using namespace std;

int main()
{
    long n;
    cin >> n;
    bool arr[n+1];
    for(long i = 1; i <= n; i++)
        arr[i] = true;
    for(long i = 3; i <= n; i += 3)
    {
        arr[i] = false;
    }
    for(long i = 5; i <= n; i += 5)
    {
        arr[i] = false;
    }
    long long sum = 0;
    for(long i = 1; i <= n; i++)
    {
        if(arr[i])
            sum += i;
    }
    cout << sum;
}
