Data Input from Serial Monitor to Control Stepper Motor with Arduino Uno

It appears that you are using 2 serial sends to send the speed and direction, reading that into 2 Strings and converting to numbers to control the stepper. It, I think, would be better to send only one packet, read it into a c-string (null terminated character array), parse the string for the data and convert to numbers to control the stepper. The serial input basics tutorial will show how to make the packet, receive and parse it.

Using the String class without knowing what you are doing can cause memory problems. See the Evils of Strings page.