Scala function for file name suffix with count number occurance

The Photo image data was saved with format, photo name.extension, cityname, yyyy-mm-dd hh:mm:ss
i am trying to write function in scala which give desired result.

Input:

john.jpg, USA,2013-09-15 14:08:15
BOB.jpg, UK,2013-09-15 14:08:15
RONY.jpg, USA,2013-09-15 19:08:15
A.PNG, USA,2018-09-15 21:08:15
TONY.jpg, CHINA,2020-09-15 19:08:15
MONY.PNG, CHINA,2021-09-15 21:08:15
RONY.jpg, CHINA,2015-09-15 19:08:15
A.PNG, JAPAN,2019-09-15 21:08:15

desired output

USA01.JPG
UK01.JPG
USA02.JPG
USA03.PNG
CHINA01.JPG
CHINA02.PNG
CHINA03.JPG
JAPAN01.PNG

There 3 pic from USA, so usa01, usa02 and usa03. similarly china01,china02 and china03

appreciate your suggestion or approach how to do this with scala.
Thanks

What have you tried? Why it didn’t work?
Do you at least have an algorithm in mind; and are just struggling with the syntax?

Also, since this is probably homework we need to know which Scala version are you using and what are you allowed to do, and what not.