package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"runtime"
	"strconv"
)

var DEBUG = true

func main() {
	defer Flush()

	Q := readi()
	b := NewBST()
	for q := 0; q < Q; q++ {
		t := readi()
		switch t {
		case 0:
			x := readi()
			b.Insert(x, true)
			println(b.Len())
		case 1:
			x := readi()
			nd := b.Find(x)
			if nd == nil {
				println(0)
			} else {
				println(1)
			}
		default:
			x := readi()
			b.Remove(x)
		}
	}

}

//
// Binary Search Tree
//
//   This is Go implementation of LLRB Tree. Some parts of code are
//   based on the paper "Left-leaning Red-Black Trees" by Robert Sedgewick.
//

// BST represents Binary Search Tree
type BST struct {
	root  *BSTNode
	size  int
	debug bool
}

// NewBST returns the pointer a BST object
func NewBST() *BST {
	t := &BST{}
	return t
}

// Len returns the size of the BST
func (t *BST) Len() int {
	return t.size
}

// Insert inserts the val on the key
func (t *BST) Insert(key int, val interface{}) bool {
	var ok bool
	t.root, ok = t.root.insert(key, val)
	t.root.color = BST_BLACK
	if ok {
		t.size++
	}
	return ok
}

func (t *BST) Debug() {
	t.debug = !t.debug
}

var dump func()

func defaultDump() {
	return
}

func (t *BST) mkDumpFunc(label string) func() {
	return func() {
		pc, file, line, _ := runtime.Caller(1)
		fmt.Fprintf(os.Stderr, "* %s [0x%x@%s:%d]\n", label, pc, file, line)
		fmt.Fprintln(os.Stderr, "```graphviz")
		fmt.Fprintf(os.Stderr, "%s", t.Graphviz())
		fmt.Fprintln(os.Stderr, "```")
	}
}

// Remove removes the value on the key
func (t *BST) Remove(key int) bool {
	//if t.debug {
	//	fmt.Fprintf(os.Stderr, "\n## Remove %d\n\n", key)
	//	dump = t.mkDumpFunc(fmt.Sprintf("Remove(%d)", key))
	//} else {
	//	dump = defaultDump
	//}

	var ok bool
	t.root, ok = t.root.remove(key)
	if t.root != nil {
		t.root.color = BST_BLACK
	}
	if ok {
		t.size--
	}
	//if t.debug {
	//	dump = defaultDump
	//}
	return ok
}

// Find returns the BSTNode that matches the key.  It returns nil if the key is not found.
func (t *BST) Find(key int) *BSTNode {
	return t.root.find(key)
}

// ForEach iterates calling fn on all the BST nodes.
func (t *BST) ForEach(fn func(nd *BSTNode, cancel func())) {
	var isCanceled bool

	cancel := func() {
		isCanceled = true
	}

	t.root.forEach(func(nd *BSTNode) bool {
		fn(nd, cancel)
		return isCanceled
	})
}

// ReverseForEach iterates like ForEach but in reverse order.
func (t *BST) ReverseForEach(fn func(nd *BSTNode, cancel func())) {
	var isCanceled bool

	cancel := func() {
		isCanceled = true
	}

	t.root.reverseForEach(func(nd *BSTNode) bool {
		fn(nd, cancel)
		return isCanceled
	})
}

// RangeForEach iterates calling fn with all the BST nodes that has keys such that low <= key < high
func (t *BST) RangeForEach(low, high int, fn func(nd *BSTNode, cancel func())) {
	var isCanceled bool

	cancel := func() {
		isCanceled = true
	}

	t.root.rangeForEach(low, high, func(nd *BSTNode) bool {
		fn(nd, cancel)
		return isCanceled
	})
}

// ReverseRangeForEach iterates calling fn with all the BST nodes that has keys such that low < key <= high in reverse order.
func (t *BST) ReverseRangeForEach(low, high int, fn func(nd *BSTNode, cancel func())) {
	var isCanceled bool

	cancel := func() {
		isCanceled = true
	}

	t.root.reverseRangeForEach(low, high, func(nd *BSTNode) bool {
		fn(nd, cancel)
		return isCanceled
	})
}

// Find returns the BSTNode that has a key which is greater than or equal to the specified key.
func (t *BST) LowerBound(key int) *BSTNode {
	return t.root.lowerBound(key)
}

// Find returns the BSTNode that has a key which is lesser than or equal to the specified key.
func (t *BST) UpperBound(key int) *BSTNode {
	return t.root.upperBound(key)
}

// String returns the string representation of the BST
func (t *BST) String() string {
	buf := new(bytes.Buffer)
	fmt.Fprintf(buf, "BST[")
	sp := ""
	t.ForEach(func(nd *BSTNode, cancel func()) {
		fmt.Fprintf(buf, "%s%s", sp, nd)
		sp = " "
	})
	fmt.Fprintf(buf, "]")
	return buf.String()
}

// Graphviz returns the graph directives of the BST in graphviz format
func (t *BST) Graphviz() string {
	buf := new(bytes.Buffer)
	fmt.Fprintf(buf, "digraph hierarchy {\n")
	fmt.Fprintf(buf, "graph [splines=line];\n")
	t.root.graphviz(buf)
	fmt.Fprintf(buf, "}\n")
	return buf.String()
}

//
// BST Node
//

// BSTNode represents the node of BST
type BSTNode struct {
	key         int
	value       interface{}
	left, right *BSTNode
	color       bool
}

// BST_RED and BST_BLACK represent colors of the BSTNode
const (
	BST_RED   = false
	BST_BLACK = true
)

// Key returns the key of the node
func (nd *BSTNode) Key() int {
	return nd.key
}

// Value returns the value of the node
func (nd *BSTNode) Value() interface{} {
	return nd.value
}

// SetValue updates the value of the node with val
func (nd *BSTNode) SetValue(val interface{}) {
	nd.value = val
}

// String returns the string representation of the node
func (nd *BSTNode) String() string {
	return fmt.Sprintf("%d:%s", nd.key, nd.value)
}

func (nd *BSTNode) find(key int) *BSTNode {
	if nd == nil {
		return nil
	}
	if key < nd.key {
		return nd.left.find(key)
	} else if nd.key < key {
		return nd.right.find(key)
	}
	return nd
}

func (nd *BSTNode) fixup() *BSTNode {
	if !nd.left.isRed() && nd.right.isRed() {
		nd = nd.rotateLeft()
	}
	if nd.left.isRed() && nd.left != nil && nd.left.left.isRed() {
		nd = nd.rotateRight()
	}
	if nd.left.isRed() && nd.right.isRed() {
		nd.flipColors()
	}
	return nd
}

func (nd *BSTNode) insert(key int, val interface{}) (*BSTNode, bool) {
	var ok bool
	if nd == nil {
		nd = &BSTNode{
			key:   key,
			value: val,
		}
		return nd, true
	} else if key < nd.key {
		nd.left, ok = nd.left.insert(key, val)
	} else if nd.key < key {
		nd.right, ok = nd.right.insert(key, val)
	} else {
		nd.value = val
	}
	return nd.fixup(), ok
}

func (nd *BSTNode) findMin() (int, interface{}) {
	p := nd
	for p.left != nil {
		p = p.left
	}
	return p.key, p.value
}

func (nd *BSTNode) removeMin() *BSTNode {
	if nd.left == nil {
		return nd.right
	}

	if !nd.left.isRed() && nd.left != nil && !nd.left.left.isRed() {
		nd = nd.moveRedLeft()
	}

	nd.left = nd.left.removeMin()

	return nd.fixup()
}

func (nd *BSTNode) moveRedLeft() *BSTNode {
	nd.flipColors()
	if nd.right != nil && nd.right.left.isRed() {
		nd.right = nd.right.rotateRight()
		nd = nd.rotateLeft()
		nd.flipColors()
	}
	return nd
}

func (nd *BSTNode) moveRedRight() *BSTNode {
	nd.flipColors()
	if nd.left != nil && nd.left.left.isRed() {
		nd = nd.rotateRight()
		nd.flipColors()
	}
	return nd
}

func (nd *BSTNode) remove(key int) (*BSTNode, bool) {
	if nd == nil {
		return nil, false
	}

	var ok bool
	if key < nd.key {
		if !nd.left.isRed() && nd.left != nil && !nd.left.left.isRed() {
			nd = nd.moveRedLeft()
		}
		nd.left, ok = nd.left.remove(key)
	} else {
		if nd.left.isRed() {
			nd = nd.rotateRight()
		}
		if nd.key == key && nd.right == nil {
			return nil, true
		}
		if !nd.right.isRed() && nd.right != nil && !nd.right.left.isRed() {
			nd = nd.moveRedRight()
		}
		if nd.key == key {
			nd.key, nd.value = nd.right.findMin()
			nd.right = nd.right.removeMin()
			ok = true
		} else {
			nd.right, ok = nd.right.remove(key)
		}
	}
	return nd.fixup(), ok
}

func (nd *BSTNode) forEach(fn func(nd *BSTNode) bool) bool {
	if nd == nil {
		return false
	}

	if nd.left != nil {
		if nd.left.forEach(fn) {
			return true
		}
	}

	if fn(nd) {
		return true
	}

	if nd.right != nil {
		if nd.right.forEach(fn) {
			return true
		}
	}
	return false
}

func (nd *BSTNode) reverseForEach(fn func(nd *BSTNode) bool) bool {
	if nd == nil {
		return false
	}

	if nd.right != nil {
		if nd.right.reverseForEach(fn) {
			return true
		}
	}

	if fn(nd) {
		return true
	}

	if nd.left != nil {
		if nd.left.reverseForEach(fn) {
			return true
		}
	}
	return false
}

func (nd *BSTNode) rangeForEach(low, high int, fn func(nd *BSTNode) bool) bool {
	if nd == nil {
		return false
	}

	if low < nd.key && nd.left != nil {
		if nd.left.rangeForEach(low, high, fn) {
			return true
		}
	}

	if low <= nd.key && nd.key < high {
		if fn(nd) {
			return true
		}
	}

	if nd.key < high && nd.right != nil {
		if nd.right.rangeForEach(low, high, fn) {
			return true
		}
	}
	return false
}

func (nd *BSTNode) reverseRangeForEach(low, high int, fn func(nd *BSTNode) bool) bool {
	if nd == nil {
		return false
	}

	if nd.key < high && nd.right != nil {
		if nd.right.reverseRangeForEach(low, high, fn) {
			return true
		}
	}

	if low < nd.key && nd.key <= high {
		if fn(nd) {
			return true
		}
	}

	if low < nd.key && nd.left != nil {
		if nd.left.reverseRangeForEach(low, high, fn) {
			return true
		}
	}
	return false
}

func (nd *BSTNode) lowerBound(key int) *BSTNode {
	if nd == nil {
		return nil
	}

	if key < nd.key && nd.left != nil {
		if res := nd.left.lowerBound(key); res != nil {
			return res
		}
	}

	if key <= nd.key {
		return nd
	}

	if nd.key < key && nd.right != nil {
		return nd.right.lowerBound(key)
	}
	return nil
}

func (nd *BSTNode) upperBound(key int) *BSTNode {
	if nd == nil {
		return nil
	}

	if nd.key < key && nd.right != nil {
		if res := nd.right.upperBound(key); res != nil {
			return res
		}
	}

	if nd.key <= key {
		return nd
	}

	if key < nd.key && nd.left != nil {
		return nd.left.upperBound(key)
	}

	return nil
}

func (nd *BSTNode) rotateLeft() *BSTNode {
	x := nd.right
	nd.right = x.left
	x.left = nd
	x.color = nd.color
	nd.color = BST_RED
	return x
}

func (nd *BSTNode) rotateRight() *BSTNode {
	x := nd.left
	nd.left = x.right
	x.right = nd
	x.color = nd.color
	nd.color = BST_RED
	return x
}

func (nd *BSTNode) flipColors() {
	nd.color = !nd.color
	if nd.left != nil {
		nd.left.color = !nd.left.color
	}
	if nd.right != nil {
		nd.right.color = !nd.right.color
	}
}

func (nd *BSTNode) isRed() bool {
	if nd == nil {
		return false
	}
	return nd.color == BST_RED
}

func (nd *BSTNode) graphviz(w io.Writer) {
	if nd == nil {
		return
	}
	if nd.left != nil {
		fmt.Fprintf(w, `%d -> %d`, nd.key, nd.left.key)
		if nd.left.isRed() {
			fmt.Fprintf(w, ` [color=red]`)
		}
		fmt.Fprintln(w)
		nd.left.graphviz(w)
	}
	if nd.right != nil {
		fmt.Fprintf(w, `%d -> %d`, nd.key, nd.right.key)
		if nd.right.isRed() {
			fmt.Fprintf(w, ` [color=red]`)
		}
		fmt.Fprintln(w)
		nd.right.graphviz(w)
	}
	if nd.isRed() {
		fmt.Fprintf(w, "%d [color=red fontcolor=red]\n", nd.key)
	} else {
		fmt.Fprintf(w, "%d [color=black fontcolor=black]\n", nd.key)
	}
}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}



Measured memory_bytes: 14700