#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pie 2*(acos(0.0))
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define endl "\n"
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define ALLAHU_AKBAR ios::sync_with_stdio(false); cin.tie(nullptr);
//typedef tree<ll, null_type, greater<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
void sir()
{
string s; cin>>s;
int n; cin>>n;
string a = "";
int pl = -1;
for(int i=0; i<s.length(); i++)
{
if(s[i]=='+')
{
pl = i;
break;
}
else a.pb(s[i]);
}
int n1 = 0;
int x = 1;
for(int i=a.length()-1; i>=0; i--)
{
n1 =+ (x *(a[i]-'0'));
x *=10;
}
string b ="";
pl++;
//cout<<s[pl]<<endl;
for(int i=pl; i<s.length(); i++)
{
if(s[i]=='+' || s[i]=='.')
{
break;
}
else b.pb(s[i]);
}
int n2 = 0;
x = 1;
for(int i=b.length()-1; i>=0; i--)
{
n2 =+ (x *(b[i]-'0'));
x *=10;
}
//cout<<a<<" "<<b<<endl;
int d = n2-n1;
ll last = n1 + (n-1) * d;
ll first = (ll)n1;
ll ans = n*(first+last)/2;
cout<<ans<<endl;
}
int main() {
ALLAHU_AKBAR
ll t = 1;
//cin>>t;
while(t--)
{
sir();
}
return 0;
}