This would have been easier to answer twenty or so years ago, before CIDR became commonplace.
I assume that by "valid" you mean something that with the common router configuration on the Internet will represent a valid endpoint host. It is perfectly possible to run an IPv4 network that has absolutely nothing to do with the Internet, in which case many assumptions about address space allocation made on the public Internet will not hold.
Some parts of the address space are easy. We have 2^32 possible addresses, and from this we can subtract things like the old Class E (first octet 240-255), RFC 1918 space (10/8, 172.16/12, 192.168/16), ranges reserved for various purposes (100.64/10, 127/8, 169.254/16, ...) and so on. There are also netblocks that you are extremely unlikely to encounter on the public Internet, like AMPRNET (netblock 44/8), but which aren't reserved per se.
However, that doesn't really get us an answer. IPv4 allocation these days is done using CIDR, which means that two adjacent netblocks may have completely different netmasks. It's perfectly possible to have subnets like 10.0.127.240/28 and 10.0.128.0/17 sitting right next to each other and belonging to the same upstream allocation, say, 10.0/9. (Yes, that is RFC 1918 space, but that's just so I don't accidentally name someone's real network.)
Ideally packed, 16 adjacent /28 blocks require a grand total of one /24 worth of address space, so you might think that it would allow the same number of hosts as a single /24. But they do not; each /28 has its own network and broadcast address, while the /24 has only one such set. So you are in a sense "wasting" an additional 30 IP addresses (16 network and 16 broadcast addresses, rather than one of each). The set of /28 blocks allow addressing a grand total of 16 × 14 = 224 hosts, whereas the single /24 allows addressing 254 hosts. This effect becomes more pronounced the smaller the subnet allocations made are. The choice whether to slice out a /29, /28, /24 or even a /20 is a business choice made by the upstream ISP, based on the customer's demonstrated needs and likely also the customer's ability and willingness to pay for the address space. I sent in a request for an IPv4 allocation for a company I worked for a little over ten years ago, and even then, getting anything larger than a /28 was not trivial.
What all this boils down to is that there is no way to calculate an exact maximum number of addressable hosts on the Internet, because even if we enumerate and take into account all reserved IP address ranges, we would still need to know the subnet allocation sizes in order to account for the varying amount of losses to network and broadcast addresses. Before CIDR, that was knowable; class A was a /8, class B was a /16 and class C was a /24. With CIDR, no such assumptions can be made.