How to add field of linked doctype in naming series

There are two doctypes A,B
B is linked to A
so in naming series of Doctype A, i need to include a field of doctype B