#include <bits/stdc++.h>
using namespace std;

class Product {a#include <iostream>
#include <string>
using namespace std;

class Product {
private:
    string name;
    string productID;
    int quantity;

public:
    // Constructor
    Product(string n, string id, int q) {
        name = n;
        productID = id;
        quantity = q;
    }

    // Add stock
    void addStock(int q) {
        quantity += q;
        cout << "Updated Quantity: " << quantity << endl;
    }

    // Remove stock with validation
    void removeStock(int q) {
        if (q > quantity) {
            cout << "Invalid input" << endl;
            exit(0);  // stop further execution
        } else {
            quantity -= q;
            cout << "Updated Quantity: " << quantity << endl;
        }
    }
};

int main() {
    string name, id;
    int initialQty;
    string operation;
    int qty;

    cin >> name >> id;
    cin >> initialQty;
    cin >> operation >> qty;

    // Input validation
    if (initialQty < 0 || qty < 0) {
        cout << "Invalid input" << endl;
        return 0;
    }

    Product p(name, id, initialQty);

    if (operation == "add") {
        p.addStock(qty);
    } 
    else if (operation == "remove") {
        p.removeStock(qty);
    } 
    else {
        cout << "Invalid input" << endl;
    }

    return 0;
}

};

class Inventory : public Product {
public:
    void displayQuantity(){ cout<<qty<<endl; }
};

int main(){
    string name,id,op;
    int qty=100;
    cin >> name >> id;
    cin >> op >> qty;
    Inventory *p = new Inventory();
    p->setProduct(name,id,qty);
    p->operate(op,qty);
    p->displayQuantity();
    delete p;
}
