#import <Foundation/Foundation.h>
#import <stdio.h>

int main(int argc, char **argv) {
  NSInteger N;
  
  scanf("%d", &N);
  
  NSMutableSet<NSNumber *> *mutableSet = [[NSMutableSet alloc] init];
  
  NSInteger v3 = 3;
  NSInteger v5 = 5;
  NSInteger sum = 0;
  while (v3 <= N) {
    if(![mutableSet containsObject: @(v3)]) {
      sum += v3;
      [mutableSet addObject: @(v3)];
    }
    v3 += 3;
  }
  while (v5 <= N) {
    if(![mutableSet containsObject: @(v5)]) {
      sum += v5;
      [mutableSet addObject: @(v5)];
    }
    v5 += 5;
  }
  NSInteger sumAll = (N + 1) * N / 2;
  printf("%ld", sumAll - sum);
  
  return 0;
}