include

include

using namespace std;
int main(){
vector<int> cost;
int c;
while(scanf("%d,", &c) > 0){
cost.push_back(c);
}
int l = cost.size();
int total_cost;
vector<int> dp(l, 0);
for(int i = 0; i < l; i ++){
if(i == 0) dp[i] = cost[0];
else if(i == 1) dp[i] = min(cost[0] + cost[1], cost[1]);
else{
dp[i] = min(dp[i - 1] + cost[i], dp[i - 2] + cost[i]);
}
// cout << dp[i]<<' ';
}
cout << min(dp[l - 1], dp[l - 2]);
}</int></int>