/*
#include <stdio.h>
#define SIZE 200
#include <string.h>
char stack [SIZE]={};
int top=-1;
void push (int data)
{
stack[++top]=data;
}
int pop ()
{
return stack [top--];
}
int main ()
{
int i,n;
char str[SIZE]={};
scanf ("%d ",&n);
for (i=n-1;i>=0;i--)
{
scanf ("%c",&str[i]);
}
for (i=0;i<n;i++)
{
if (i%3==0&&i!=0)
{
push (',');
}
push (str[i]);
}
n=top+1;
for (i=0;i<n;i++)
{
printf ("%c",pop());
}
return 0;
}
*/
/*
#include <stdio.h>
#define SIZE 100
#include <string.h>
char stack [SIZE]={};
int top=-1;
void push (char data)
{
stack [++top]=data;
}
char pop ()
{
return stack [top--];
}
int main ()
{
int i;
char str1[SIZE]={},str2[SIZE]={};
int str3[500]={};
int la,lb,k,lc;
gets (str1);
gets (str2);
la=strlen(str1);
lb=strlen(str2);
for (i=la-1;i>=0;i--)
{
str3[la-i-1]=str1[i]-'0';
}
for (i=strlen(str2)-1;i>=0;i--)
{
str3[lb-i-1]+=str2[i]-'0';
}
lc=la>lb?la:lb;
for (i=0;i<lc;i++)
{
if (str3[i]>=10)
{
str3[i+1]+=str3[i]/10;
}
push(str3[i]%10+'0');
}
if(str3[i]!=0) push(str3[i]+'0');
k=top+1;
for (i=0;i<k;i++)
{
printf ("%c",pop());
}
return 0;
}
*/
/*
#include <stdio.h>
#define SIZE 100
int stack [SIZE]={};
int top=-1;
void push (int data)
{
stack[++top]=data;
}
int pop ()
{
return stack [top--];
}
int main ()
{
int k,a=0,i,sum=0;
scanf ("%d",&k);
for (i=1;i<=k;i++)
{
scanf ("%d",&a);
if(a==0)
{
pop();
}
else
{
push(a);
}
}
k=top+1;
for(i=0;i<k;i++)
{
sum+=pop();
}
printf("%d",sum);
}
*/