import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static class Node {
public int value;
public Node next;
public Node() {
value = 0;
next = null;
}
public Node(int newValue, Node newNext) {
value = newValue;
next = newNext;
}
}
public static class Queue {
private int size;
private Node first;
private Node last;
public Queue() {
size = 0;
first = null;
last = null;
}
public void push(int v) {
Node newNode = new Node(v, null);
if (size == 0) {
first = last = newNode;
} else {
last.next = newNode;
last = newNode;
}
size++;
}
public boolean pop() {
boolean ret = false;
if (size > 0) {
int val = first.value;
first = first.next;
size--;
ret = true;
}
return ret;
}
public boolean front() {
boolean ret = false;
if (size > 0) {
System.
out.
print(first.
value); ret = true;
}
return ret;
}
public int getSize() {
return size;
}
public void clear() {
first = null;
last = null;
size = 0;
}
}
public static void main
(String[] args
) { Queue q = new Queue();
int n;
Scanner scan
= new Scanner
(System.
in); while ((s = scan.next()) != null) {
switch(s) {
case "size": System.
out.
println(q.
getSize()); break; case "push":
n = scan.nextInt();
q.push(n);
break;
case "pop":
if (q.pop() == false) {
}
break;
case "front":
if (q.front() == false) {
}
break;
case "clear":
q.clear();
break;
case "exit":
return;
default: break;
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluIHsKCXB1YmxpYyBzdGF0aWMgY2xhc3MgTm9kZSB7CgkJcHVibGljIGludCB2YWx1ZTsKCQlwdWJsaWMgTm9kZSBuZXh0OwoJCQoJCXB1YmxpYyBOb2RlKCkgewoJCQl2YWx1ZSA9IDA7CgkJCW5leHQgPSBudWxsOwoJCX0KCQlwdWJsaWMgTm9kZShpbnQgbmV3VmFsdWUsIE5vZGUgbmV3TmV4dCkgewoJCQl2YWx1ZSA9IG5ld1ZhbHVlOwoJCQluZXh0ID0gbmV3TmV4dDsKCQl9Cgl9CgkKCXB1YmxpYyBzdGF0aWMgY2xhc3MgUXVldWUgewoJCXByaXZhdGUgaW50IHNpemU7CgkJcHJpdmF0ZSB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