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

int main(int argc, char **argv) {
  NSInteger N;
  
  scanf("%ld", &N);
  
  NSInteger num3 = N / 3;
  NSInteger num5 = N / 5;
  NSInteger num15 = N / 15;
  
  NSInteger sum = (N + 1) * N / 2;
  sum -= 3 * (num3 + 1) * num3 / 2;
  sum -= 5 * (num5 + 1) * num5 / 2;
  sum += 15 * (num15 + 1) * num15 / 2;

  printf("%ld", sum);
  return 0;
}