program fizzbuzz
 
 implicit none
 integer(8) :: n,ans,i
 integer(8),allocatable :: a(:)

 read*,n
 allocate(a(n))
 ans=0
 
 
 do i=1,n
  if(mod(i,3)==0 .or. mod(i,5)==0) then 
      a(i)=0
  else
      a(i)=i
     ! print*,a(i)
  end if
  ans=ans+a(i)
 end do 
   

 print*,ans

end program fizzbuzz