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