/*
* @Author: Kabid
* @Date:   2020-04-16 00:45:39
*/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define in(x)  scanf("%d", &x);
#define ins(x) scanf("%s", &x);
#define out(x) printf("%d", x);
#define outs(x) printf("%s", x);
#define _ putchar(' ');
#define lin puts("");

int t,i,j=0,k,l,x=0,r,la,lb;
int c=0,m=1,ci=0,ca=0,cb=0;
char s[100001];
char sa[501],sb[501];
int a[1001],b[1001]={0},e[101]={0},g[101]={0},d;
int main(){
	in(x)
	for(i=1;i<=x;i++){
		if(i%15!=0 && i%3!=0&&i%5!=0){
			c+=i;
		}
	}
	out(c)lin


		

	
	
	
	
	


    return 0;
 }
	
		
