#include<bits/stdc++.h>
using namespace std;
long long sum=0;
int f(){
int n=0;
cin >> n;
if(n==0){
return n;
}
if(n!=0 && n%2==0){
long long r=0,branch1=0,branch2=0;
r=f();
branch1=abs(n-r);
if(branch1==n && r==0){branch1=0;}
r=f();
branch2=abs(n-r);
if(branch2==n && r==0){branch2=0;}
sum=sum+branch1+branch2;
}
if(n!=0 && n%2==1){
long long r=0,branch1=0,branch2=0,branch3=0;
r=f();
branch1=abs(n-r);
if(branch1==n && r==0){branch1=0;}
r=f();
branch2=abs(n-r);
if(branch2==n && r==0){branch2=0;}
r=f();
branch3=abs(n-r);
if(branch3==n && r==0){branch3=0;}
sum=sum+branch1+branch2+branch3;
}
return n;
}
int main(){
f();
cout<<sum;
}