from typing import Optional


class Node:
    def __init__(self, data: int, next_=None) -> None:
        self.data: int = data
        self.next = next_

    def __str__(self) -> str:
        return f"<Node: {self.data}>"


class Stack:
    def __init__(self):
        self.head: Node = None
        self.size = 0

    def __len__(self) -> int:
        return self.size

    def push(self, item) -> None:
        n = Node(item)
        if not self.head:
            self.head = n
        else:
            n.next = self.head
            self.head = n
        self.size += 1

    def pop(self) -> Optional[int]:
        if not self.head:
            return None
        old = self.head.data
        self.head = self.head.next
        self.size -= 1
        return old

    def peek(self) -> int:
        return self.head.data
