Does this do it in D4?

=IF(C4="AL",LEFT(C3,5)-IF(C5="",0,D5),"")