main(): add key_types_length and reuse it in two places instead of hardcoded values