#include<bits/stdc++.h>
using namespace std;
int data[150][150];
int i;
int solve(int idx,int idxy){
  if(idx==i+1){
    return 0;
  }
  if(data[idx][idxy]==-1){
    return 0;
  }
  int ret=data[idx][idxy];
  if(idx < i/2){
    ret=max(ret+solve(idx+1,idxy),ret+solve(idx+1,idxy+1));
  }else{
    ret=max(ret+solve(idx+1,idxy),ret+solve(idx+1,idxy-1));
  }
  return ret;
}
	     
int main(){
  int w,j;
  i=j=0;
  memset(data,-1,sizeof(data));
  while(cin >> w){
    data[i][j]=w;
    j++;
    char c = cin.get();
    if(c == '\n'){
      i++;
      j=0;
    }
  }
  cout<<i<<endl;
  cout<<solve(0,0)<<endl;
}