program calendar
  implicit none
  integer :: n, k, x = 0, i, j
  read(*,*) n, k
  n = n-2
  if (n >= 11) then
    x = n/11*5
    n = mod(n,11)
  end if
  do i = 1, 5
    do j = 1, n
      if(mod(8*j+9*i-2,11) == k) x = x+1
    end do
  end do
  write(*,'(i0)') x
end program calendar