 program FizzBuzz
      implicit none
      
      integer K,a(3),gcd,Mi,i,j,l
      read(*,*) K
      a=1
      gcd=0
      do i=1,K
        a(0)=i
      do j=1,K
        a(1)=j
      do l=1,K
         a(2)=l
         Mi=min(a(0),a(1),a(2))
         
         1 if (mod(a(0),Mi)==0.and.mod(a(1),Mi)==0.and.mod(a(2),Mi)==0) then
            gcd=gcd+Mi
         else
             Mi=Mi-1
             go to 1
         end if
      end do
      end do
      end do
      
      write(*,'(i0)') gcd
      stop 
      end program FizzBuzz