Hello Alice,
ACS is really poor about personalized expression. You cannot use <% %> balisis like Adobe classic...
Like you said, you can construct your personnalisation with dynamic text.
First dynamic bloc 'A' will use the condition: "Firstname" is not empty and the Default Dynamic bloc will personalize the subject with no Firstname.
I hope that could help you,
Regards,