import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	}
  static long sum(long n){
    return (1 + n) * n / 2;
  }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	}
  static long sum(long n){
    return (1 + n) * n / 2;
  }
} Main public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	} main {
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15) System.out.println System.out System System.out sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15 sum(n)-sum(n/3)*3-sum(n/5)*5 sum(n)-sum(n/3)*3-sum(n/5)*5 sum(n) sum n sum(n/3)*3 sum(n/3) sum n/3 n 3 3 sum(n/5)*5 sum(n/5) sum n/5 n 5 5 sum(n/15)*15 sum(n/15) sum n/15 n 15 15 String[] args args static long sum(long n){
    return (1 + n) * n / 2;
  } sum {
    return (1 + n) * n / 2;
  } return (1 + n) * n / 2; (1 + n) * n / 2 (1 + n) * n (1 + n) 1 n n 2 long n n public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	}
  static long sum(long n){
    return (1 + n) * n / 2;
  }
} public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	}
  static long sum(long n){
    return (1 + n) * n / 2;
  }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    System.out.println(sum(n)-sum(n/3)*3-sum(n/5)*5+sum(n/15)*15);
        
	
	}
  static long sum(long n){
    return (1 + n) * n / 2;
  }
}
