import java.util.*;

public class Main {
  private static long solve(int n) {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  }
}
 import java.util.*; util.* java public class Main {
  private static long solve(int n) {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  }
} Main private static long solve(int n) {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  } solve {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  } long result = 0; result 0 int i = 1; i 1 while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    } i <= n i n {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    } if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      } i % 3 != 0 && i % 5 != 0 i % 3 != 0 i % 3 i 3 0 i % 5 != 0 i % 5 i 5 0 {
        result += i;
      } result += i result i i ++ i return result; result int n n public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  } main {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) System.out.println(solve(sc.nextInt())) System.out.println System.out System System.out solve(sc.nextInt()) solve sc.nextInt() sc.nextInt sc sc.close() sc.close sc String[] args args public class Main {
  private static long solve(int n) {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  }
} public class Main {
  private static long solve(int n) {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  }
} Main
import java.util.*;

public class Main {
  private static long solve(int n) {
    long result = 0;
    int i = 1;
    while (i <= n) {
      if (i % 3 != 0 && i % 5 != 0) {
        result += i;
      }
      i ++;
    }
    return result;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println(solve(sc.nextInt()));
    sc.close();
  }
}

