#include <bits/stdc++.h>
using namespace std;
int main(){
int n,i,c,s = 0;
cin>>n;
for(i = 1;i <= n;i++){
c = 0;
if(i % 2 == 0){
c++;
}
if(i % 3 == 0){
c++;
}
if(i % 5 == 0){
c++;
}
if(i % 7 == 0){
c++;
}
if(c >= 2){
s = s + i;
}
}
cout<<s<<endl;
}
/**************************************************************
Problem: 1449
User: admin
Language: C++
Result: Accepted
Time:25 ms
Memory:2072 kb
****************************************************************/