import java.util.*;
public class Main{
     public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     }
} import java.util.*; util.* java public class Main{
     public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     }
} Main public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     } main {
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan long b = 0; b 0 for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         } int i=1; int i=1; i 1 i<=a i a i++ i++ i {
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         } {
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         } if ( i % 3 == 0 || i % 5 == 0 ) continue; i % 3 == 0 || i % 5 == 0 i % 3 == 0 i % 3 i 3 0 i % 5 == 0 i % 5 i 5 0 continue; b+=i b i System.out.println(b) System.out.println System.out System System.out b String []args args public class Main{
     public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     }
} public class Main{
     public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     }
} Main
import java.util.*;
public class Main{
     public static void main(String []args){
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         
         long b = 0;
         for (int i=1;i<=a;i++){
             if ( i % 3 == 0 || i % 5 == 0 ) continue;
            
             b+=i; 
         }
         
         System.out.println(b);
     }
}