      program FizzBuzz
      implicit none
      integer N,i,S
      character a(1000000)
      read(*,*) N
      S=0
      do i =0, N-1
         if (mod((i+1),15)==0) then
            a(i)="FizzBuzz"
         else if (mod((i+1),3)==0) then
            a(i)="Fizz"
         else if (mod((i+1),5)==0) then
            a(i)="Buzz"
         else 
            S=S+i+1
         end if
      end do
      write(*,*) S
      stop 
      end program FizzBuzz
