import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 }
} import java.util.Scanner; Scanner java.util public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 }
} Main public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 } main {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 } Scanner kbd = new Scanner(System.in); kbd new Scanner(System.in) int n =kbd.nextInt(); n kbd.nextInt() kbd.nextInt kbd long c=0; c 0 for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   } int i=1; int i=1; i 1 i<n+1 i n+1 n 1 i++ i++ i {
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   } {
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   } if(i%3!=0&&i%5!=0){
       c=c+i;
     } i%3!=0&&i%5!=0 i%3!=0 i%3 i 3 0 i%5!=0 i%5 i 5 0 {
       c=c+i;
     } c=c+i c c+i c i System.out.println(c) System.out.println System.out System System.out c String[] args args public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 }
} public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 }
} Main
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int n =kbd.nextInt();
   long c=0;
   for(int i=1;i<n+1;i++){
     if(i%3!=0&&i%5!=0){
       c=c+i;
     }
   }
   System.out.println(c);
 }
}
