#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string sum(string str1, string str2) {
if (str1.size() == 0) {
return str2;
}
if (str2.size() == 0) {
return str1;
}
int maxLength = max(str1.length(), str2.length());
//定义一个存贮结果的字符串,长度要比最大长度字符串还长一位,用于存储可能出现的进位
string result;
//翻转两个字符串
reverse(str1.begin(), str1.end());
reverse(str2.begin(), str2.end());
//反转后的结果分别为:
//954321
//321
int minLength = min(str1.length(), str2.length());
//进位
int carry = 0;
//当前位上的数值
int currentNum = 0;
//循环变量
int i = 0;
for (; i < minLength; i++) {
//分别获取两个字符对应的字面数值,然后相加,再加上进位
currentNum = str1.at(i) + str2.at(i) - 2 * '0' + carry;
//获取进位
carry = currentNum / 10;
//处理当前位的最终值
currentNum %= 10;
//保存当前位的值到最终的字符缓冲区中
result.push_back(char(currentNum + '0'));
}
if (str1.length() < str2.length()) {
//选择
str1 = str2;
}
for (; i < str1.length(); i++) {
//分别获取两个字符对应的字面数值,然后相加,再加上进位
currentNum = str1.at(i) - '0' + carry;
//获取进位
carry = currentNum / 10;
//处理当前位的最终值
currentNum %= 10;
//保存当前位的值到最终的字符缓冲区中
result.push_back(char(currentNum + '0'));
}
//处理最后一个的进位(当循环结束后,是不是还可能会有一个进位)
if (carry > 0) {
result.push_back(char(carry + '0'));
}
//最后翻转恢复字符串,再返回
reverse(result.begin(), result.end());
return result;
}
int main() {
string str1 ,str2;
cin >> str1 >> str2;
string str3 = sum(str1, str2);
cout << str3 << endl;
return 0;
}