import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] v = sc.next().split(",");
        int[] dp = new int[v.length+1];

        dp[0] = Integer.parseInt(v[0]);
        dp[1] = Integer.parseInt(v[1]);
        for(int i=2;i<v.length;++i) {
            int cur = Integer.parseInt(v[i]);
            dp[i] = cur + min(dp[i-1],dp[i-2]  );
        }

        System.out.println(min(dp[v.length-1],dp[v.length-2]));


    }
    public static int min(int... a) {
        return Arrays.stream(a).min().getAsInt();
    }



}