<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_publickey(keydata):
 """Load the public key from a PEM encoded string."""

    try:
        key = serialization.load_pem_public_key(
            keydata,
            backend=default_backend(),
        )
        return key
    except ValueError:
        key = serialization.load_pem_private_key(
            keydata,
            password=None,
            backend=default_backend(),
        )
        key = key.public_key()
        return key