#include <stdio.h>
#include <stdbool.h>

static inline int getc_term(int const term) {
  int const c = getchar();
  return ( c == EOF ? term : c);
}

void main(){
  int x_1 = -2147483648;
  int x_2 = 0;
  int x_3 = 0;
  bool x_4 = true;
  while (x_4)
  {
    int const t_5 = getc_term(0);
    if (t_5 == 0)
    
      x_4 = false;
    int const t_6 = x_3;
    if ((t_5 >= 48) && (t_5 <= 57))
    
      x_3 = (10 * t_6) + (t_5 - 48);
    else {
      x_3 = 0;
      int const t_7 = x_2;
      int const t_8 = t_7 + t_6;
      if (t_5 == 44)
      
        x_2 = t_8;
      else {
        x_2 = 0;
        int const t_9 = x_1;
        int const t_10 = (t_9 < t_8 ? t_8 : t_9);
        if (t_5 == 124)
        
          x_1 = t_10;
        else {
          x_1 = -2147483648;
          printf("%d\n",t_10);
        }
      }
    }
  }
}
