Feel free to optimize the code, but my sketch should work fine for OP's basic requirements.
Reminder for OP to look up Serial Input Basics - updated for a very comprehensive tutorial on serial communication, which include some more advanced parsing techniques. Don't watch YouTube for this stuff, there are too many sketchy tutorials, especially concerning serial communication.