#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
getline(cin, s);
int a, b, last;
s.erase(remove(s.begin(), s.end(), ' '), s.end());
// Check if input contains "..."
bool str_end = s.find("...") != string::npos;
vector<int> terms;
string temp = "";
for (char ch : s) {
if (isdigit(ch)) {
temp += ch;
} else if (ch == '+' || ch == '.') {
if (!temp.empty()) {
terms.push_back(stoi(temp));
temp = "";
}
}
}
if (!temp.empty()) terms.push_back(stoi(temp)); // last number if no str_end
a = terms[0];
b = terms[1];
cin >> last;
int d = b - a;
int n = (last - a) / d + 1;
int sum = (2 * a + (n - 1) * d) * n / 2;
cout << sum << "\n";
return 0;
}