1import java.util.*;
2import java.lang.*;
3interface IntNumber
4{
5 void ins(int item);
6 int delt();
7}
8
9class HackerEarth implements IntNumber
10{
11 private int stck[];
12 private int pos;
13
14 HackerEarth(int size)
15 {
16 stck = new int[size];
17 pos = -1;
18 }
19 public void ins(int item)
20 {
21 if(pos==stck.length-1)
22 System.out.println("Overflow");
23 else
24 stck[++pos] = item;
25 }
26
27 public int delt()
28 {
29 if(pos < 0)
30 {
31 System.out.println("Underflow");
32 return 0;
33 }
34 else
35 return stck[pos--];
36 }
37}
38
39public class Main
40{
41 public static void main(String args[])
42 {
43 HackerEarth obj = new HackerEarth(3);
44 for(int i=0; i<4; i++) obj.ins(i);
45 for(int i=0; i<=3; i++)
46 System.out.println(obj.delt());
47 }
48}