f=lambda N,P=1,p=1:len(-N*f"{P:b}")or f(N-P**p%-~p,P-P**p%~p*P,p+1)
Attempt This Online!
Disclaimer: This one has one flaw which is that it is "zero-based" which is stretching the rules, I suppose. But I'd still very much like to show it off.
Obviousy, this is heavily based on @dingledooper's answer.
How?
This leverages a bit of elementary number theory, i.e. Fermat's little theorem, to squeeze out a few bytes.
The basic strategy is the same as dingledooper's: Use the nascent primorial to identify the next prime.What we do differently is when testing the next prime number candidate \$p\$ we raise the primorial \$P\$ to one less power, \$P^{p-1}\mod p\$ instead of \$P^p \mod p\$ That way we know the value can only be \$1\$ (iff \$p\$ is indeed a prime) or \$0\$. The value can, for example, directly be used to decrement the prime number counter. The conditional update of the primorial is also streamlined.
bsr
bit-scan reverse +ret
), but would take much more work for this question. (You could approximate the answer by summing bit-lengths (logs) of each prime, but low bits can make the difference between carry-out to a new bit-pos.) \$\endgroup\$