#include<iostream>
#include<string>

using namespace std;
const int MAX = 100;
typedef string mytype;

class Add_Stack{
public:
	Add_Stack();
	void push(mytype num);
	void pop();
    mytype Top();
	bool IsEmpty() const;
	bool IsFull() const;
private:
	string arr[MAX];
	int top;
};
Add_Stack::Add_Stack(){  // 생성자

	top = -1;
}
bool Add_Stack::IsEmpty() const
{
	return(top == -1);
}
bool Add_Stack::IsFull() const
{
	return (top == MAX - 1);
}
void Add_Stack::push(mytype num)
{
	if (IsFull())
		cout << "Error: the stack is full." << endl;
	top++;
	arr[top] = num[top];
}
void Add_Stack::pop()
{
	if (IsEmpty())
	{
		cout << "Error : Stack is Empty" << endl;
	}
	else
	{
		top--;
	}
	
}
mytype Add_Stack::Top()
{
	if (IsEmpty())
		cout << "Error : Stack is Empty" << endl;
	else
	{
		return arr[top];
	}
}

int main(){

	Add_Stack one, two, result;
	mytype a, b;
	int result_num, carry=0;
	cout << "덧셈할 두 수를 입력해주세요 :";
	cin >> a >> b;
	for (int i = 0;; i++)
	{
		if (a[i] == NULL)
		{
			int one_last_index = i - 1;
			break;
		}
		one.push(a);
 	}
	for (int i = 0;; i++)
	{
		if (b[i] == NULL)
		{
			int two_last_index = i - 1;
			break;
		}
		two.push(b);
	}
	while (!one.IsEmpty() || !two.IsEmpty())
	{
		result_num = atoi(one.Top().c_str()) + atoi(two.Top().c_str());
		one.pop();
		two.pop();
		result.push(to_string((result_num % 10 )+carry));
		carry = (result_num / 10);
	}
	if (carry != 0)
	{
		result.push(to_string(carry));
	}
	while (!result.IsEmpty())
	{
		cout << result.Top() << endl;
		result.pop();
	}
	return 0;
}