word equation numbers

#include <iostream>
#include <string>

int main() {
    std::string input;
    std::cout << "Enter a word equation: ";
    std::getline(std::cin, input);

    int result = 0;
    char operation = '+';
    std::string currentNumber;

    for (char& ch : input) {
        if (std::isdigit(ch)) {
            currentNumber += ch;
        } else {
            int number = std::stoi(currentNumber);
            if (operation == '+') {
                result += number;
            } else if (operation == '-') {
                result -= number;
            }
            operation = ch;
            currentNumber = "";
        }
    }

    int lastNumber = std::stoi(currentNumber);
    if (operation == '+') {
        result += lastNumber;
    } else if (operation == '-') {
        result -= lastNumber;
    }

    std::cout << "Result: " << result << std::endl;

    return 0;
}