#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word;
    std::string w = "No";
    int64_t a,b,c,d,e,f;
    std::cin>> a;

    c = 0;

    for( int i = 1; i <= a; i++ )
    {
        if( i % 15 == 0 )
        {
            //break;
        }
        else if( i % 3 != 0
                 && i % 5 != 0 )
        {
            c += i;
        }
    }

    std::cout<< c;

}
