Providing that you'll use apache you'd better go with 40 IPs. I'm just quoting:
Name-Based VirtualHosts and SSL
As a rule, it is impossible to host more than one SSL virtual host on
the same IP address and port. This is because Apache needs to know the
name of the host in order to choose the correct certificate to setup
the encryption layer. But the name of the host being requested is
contained only in the HTTP request headers, which are part of the
encrypted content. It is therefore not available until after the
encryption is already negotiated. This means that the correct
certificate cannot be selected, and clients will receive certificate
mismatch warnings and be vulnerable to man-in-the-middle attacks.
In reality, Apache will allow you to configure name-based SSL virtual
hosts, but it will always use the configuration from the first-listed
virtual host (on the selected IP address and port) to setup the
encryption layer. In certain specific circumstances, it is acceptable
to use a single SSL configuration for several virtual hosts. In
particular, this will work if the SSL certificate applies to all the
virtual hosts. For example, this will work if: [...]
Src: http://wiki.apache.org/httpd/NameBasedSSLVHosts