#include<bits/stdc++.h>
#include <climits>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
const ll INF = 1e17+7;
/*
// _ __ ___ __ __ _______ _______
// / | / / / _ \ \ \__\ \\__ __\\ __ \
// / |/ / / /_\ \ \ ___ \ \ \ \ \ \ \
// / /| / / ____ \ \ \ \ \ _\ \___\ \/ /
// /_/ |_/ /_/ \__\ \_\ \_\\______\\___/
ID: mdnahidibnaharun
LANG: C++
TASK: practice
*/
void solve(){
string s; cin >> s;
ll a=s[0]-'0',b=s[2]-'0';
ll x; cin >> x;
ll ans =2*a+(x-1)*(b-a);
ans *= x;
cout<<ans/2;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int t;cin>>t;
// while(t--){
solve();
// cout<<endl;
// }
return 0;
}