import java.util.*;

public class Main {
public static void main(String[] args) {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	}
} import java.util.*; util.* java public class Main {
public static void main(String[] args) {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	}
} Main public static void main(String[] args) {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	} main {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) int N= keyboard.nextInt(); N keyboard.nextInt() keyboard.nextInt keyboard int[] ans = new int[N+1]; ans new int[N+1] N+1 N 1 for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
} int i = 1; int i = 1; i 1 i<N+1 i N+1 N 1 i++ i++ i {
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
} {
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
} if(i%15 == 0){
    ans[i] ++;
    } i%15 == 0 i%15 i 15 0 {
    ans[i] ++;
    } ans[i] ++ ans[i] ans i if(i%5 == 0){
    ans[i] ++;
    } i%5 == 0 i%5 i 5 0 {
    ans[i] ++;
    } ans[i] ++ ans[i] ans i if(i%3 == 0){
    ans[i] ++;
    } i%3 == 0 i%3 i 3 0 {
    ans[i] ++;
    } ans[i] ++ ans[i] ans i long sum = 0; sum 0 for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
} int j = 1; int j = 1; j 1 j<N+1 j N+1 N 1 j++ j++ j {
    if(ans[j] ==0){sum +=j;
    }
} {
    if(ans[j] ==0){sum +=j;
    }
} if(ans[j] ==0){sum +=j;
    } ans[j] ==0 ans[j] ans j 0 {sum +=j;
    } sum +=j sum j System.out.println(sum) System.out.println System.out System System.out sum keyboard.close() keyboard.close keyboard String[] args args public class Main {
public static void main(String[] args) {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	}
} public class Main {
public static void main(String[] args) {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	}
} Main
import java.util.*;

public class Main {
public static void main(String[] args) {
		
Scanner keyboard = new Scanner(System.in); 
		
int N= keyboard.nextInt();
int[] ans = new int[N+1]; 
		
for(int i = 1; i<N+1; i++){
    if(i%15 == 0){
    ans[i] ++;
    }
    if(i%5 == 0){
    ans[i] ++;
    }
    if(i%3 == 0){
    ans[i] ++;
    }
}
		
long sum = 0;

for(int j = 1; j<N+1; j++){
    if(ans[j] ==0){sum +=j;
    }
}

	System.out.println(sum);
	keyboard.close();	

	}
}
