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