import java.util.Scanner;
public class MySolution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String s = in.nextLine();
String[] split = s.split(",");
int[] nums = new int[split.length];
for (int i = 0; i < split.length; i++) {
nums[i] = Integer.parseInt(split[i]);
}
System.out.println(pickUpOrGiveUp(0, nums, new int[nums.length], 0));
}
}
private static int pickUpOrGiveUp(int round, int[] nums, int[] preScores, int score) {
if (round == nums.length) {
return score;
}
// 当前轮次分数
preScores[round] = score;
if (round > 3) {
return Math.max(pickUpOrGiveUp(round + 1, nums, preScores, score + nums[round]), pickUpOrGiveUp(round + 1, nums, preScores, preScores[round - 3]));
} else {
return Math.max(pickUpOrGiveUp(round + 1, nums, preScores, score + nums[round]), pickUpOrGiveUp(round + 1, nums, preScores, 0));
}
}
}