Sanket and strings

How to approach this problem…