package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, x, y, xx, yy int
	cnt1 := 0
	cnt2 := 0
	cnt3 := 0
	cnt4 := 0
	fmt.Fscanf(in, "%d %d %d\n", &n, &xx, &yy)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		if x != xx {
			if xx > x {
				cnt1++
			} else {
				cnt2++
			}
		}
		if y != yy {
			if yy > y {
				cnt3++
			} else {
				cnt4++
			}
		}
	}

	maxx := max(max(cnt1,cnt2), max(cnt3,cnt4))
	fmt.Fprintf(out, "%d\n", maxx)
	if maxx < 0 {
		return
	}
	if maxx == cnt1 {
		fmt.Fprintf(out, "%d %d\n", xx - 1, yy)
		return
	}
	if maxx == cnt2 {
		fmt.Fprintf(out, "%d %d\n", xx + 1, yy)
		return
	}
	if maxx == cnt3 {
		fmt.Fprintf(out, "%d %d\n", xx, yy - 1)
		return
	}
	fmt.Fprintf(out, "%d %d\n", xx, yy + 1)
}

package main

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

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

// 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...)
}

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

// 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
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// 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 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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	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)
}

func main() {
	defer Flush()

	n := readi()
	sx := readi()
	sy := readi()
	var u, d, r, l int
	for i := 0; i < n; i++ {
		x := readi()
		y := readi()
		if x < sx {
			l++
		}
		if sx < x {
			r++
		}
		if y < sy {
			d++
		}
		if sy < y {
			u++
		}
	}
	a := make([][2]int, 4)
	dx := []int{-1, 0, 1, 0}
	dy := []int{0, -1, 0, 1}
	a[0][0] = l
	a[0][1] = 0
	a[1][0] = d
	a[1][1] = 1
	a[2][0] = r
	a[2][1] = 2
	a[3][0] = u
	a[3][1] = 3
	sort.Slice(a, func(i, j int) bool { return a[i][0] > a[j][0] })
	i := a[0][1]
	println(a[0][0])
	println(sx+dx[i], sy+dy[i])
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n int
var sx, sy int
var X, Y []int

func main() {
	n = ReadInt()
	sx, sy = ReadInt2()

	X, Y = make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x, y := ReadInt2()
		X[i], Y[i] = x, y
	}

	l, r, u, d := 0, 0, 0, 0
	for i := 0; i < n; i++ {
		x, y := X[i], Y[i]

		if x <= sx-1 {
			l++
		}
		if x >= sx+1 {
			r++
		}
		if y <= sy-1 {
			d++
		}
		if y >= sy+1 {
			u++
		}
	}

	maxi := Max(l, r, u, d)
	fmt.Println(maxi)
	if l == maxi {
		fmt.Println(sx-1, sy)
	} else if r == maxi {
		fmt.Println(sx+1, sy)
	} else if d == maxi {
		fmt.Println(sx, sy-1)
	} else {
		fmt.Println(sx, sy+1)
	}
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n, sx, sy int
var X, Y []int

func main() {
	n, sx, sy = ReadInt3()
	X, Y = make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x, y := ReadInt2()
		X[i], Y[i] = x, y
	}

	cx, cy := []int{}, []int{}
	for i := 0; i < n; i++ {
		x, y := X[i], Y[i]
		if x == sx {
			cx = append(cx, x)
		} else {
			cx = append(cx, x)
			cx = append(cx, sx)
		}
		if y == sy {
			cy = append(cy, y)
		} else {
			cy = append(cy, y)
			cy = append(cy, sy)
		}
	}

	sort.Sort(sort.IntSlice(cx))
	sort.Sort(sort.IntSlice(cy))

	pcx, pcxCount := RunLengthEncoding(cx)
	pcy, pcyCount := RunLengthEncoding(cy)
	// ちゃんと端っこから数える
	for i := len(pcxCount) - 1; i >= 0; i-- {
		if pcx[i] == sx {
			break
		}
		// 累積和は不要
		if i+1 > len(pcxCount)-1 {
			continue
		}
		pcxCount[i] += pcxCount[i+1]
	}
	for i := 0; i < len(pcxCount); i++ {
		if pcx[i] == sx {
			break
		}
		// 累積和は不要
		if i-1 < 0 {
			continue
		}
		pcxCount[i] += pcxCount[i-1]
	}
	for i := len(pcyCount) - 1; i >= 0; i-- {
		if pcy[i] == sy {
			break
		}
		// 累積和は不要
		if i+1 > len(pcyCount)-1 {
			continue
		}
		pcyCount[i] += pcyCount[i+1]
	}
	for i := 0; i < len(pcyCount); i++ {
		if pcy[i] == sy {
			break
		}
		// 累積和は不要
		if i-1 < 0 {
			continue
		}
		pcyCount[i] += pcyCount[i-1]
	}
	// PrintDebug("pcx: %v\n", pcx)
	// PrintDebug("pcxCount: %v\n", pcxCount)
	// PrintDebug("pcy: %v\n", pcy)
	// PrintDebug("pcyCount: %v\n", pcyCount)

	mx, my := 0, 0
	ansx, ansy := 0, 0
	// sxにx座標を固定
	for i := 0; i < len(pcyCount); i++ {
		if pcy[i] == sy {
			continue
		}
		if mx < pcyCount[i] {
			mx = pcyCount[i]
			ansy = pcy[i]
		}
	}
	// syにy座標を固定
	for i := 0; i < len(pcxCount); i++ {
		if pcx[i] == sx {
			continue
		}
		if my < pcxCount[i] {
			my = pcxCount[i]
			ansx = pcx[i]
		}
	}

	if mx > my {
		// x座標はsx
		fmt.Println(mx)
		fmt.Println(sx, ansy)
	} else {
		// y座標はsy
		fmt.Println(my)
		fmt.Println(ansx, sy)
	}
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []int) ([]int, []int) {
	runes := []int{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []int, L []int) []int {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []int{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
	- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, sx, sy := 0, 0, 0
	fmt.Fscanf(in, "%d %d %d\n", &n, &sx, &sy)
	w, e, nor, s := 0, 0, 0, 0
	x, y := 0, 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		if x < sx {
			w++
		} else if x > sx {
			e++
		}
		if y < sy {
			s++
		} else if y > sy {
			nor++
		}
	}
	if w >= e && w >= nor && w >= s {
		fmt.Fprintf(out, "%d\n", w)
		fmt.Fprintf(out, "%d %d\n", sx-1, sy)
	} else if e >= w && e >= nor && e >= s {
		fmt.Fprintf(out, "%d\n", e)
		fmt.Fprintf(out, "%d %d\n", sx+1, sy)
	} else if nor >= w && nor >= e && nor >= s {
		fmt.Fprintf(out, "%d\n", nor)
		fmt.Fprintf(out, "%d %d\n", sx, sy+1)
	} else {
		fmt.Fprintf(out, "%d\n", s)
		fmt.Fprintf(out, "%d %d\n", sx, sy-1)
	}
	return
}

func gcd(a, b uint64) uint64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

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

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

func ok(a, b int) bool {
	if min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {
		return true
	}
	return false
}

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60
const INF_INT32 = math.MaxInt32
const INF_BIT30 = 1 << 30

var n int
var sx, sy int
var X, Y []int

func main() {
	n = ReadInt()
	sx, sy = ReadInt2()

	X, Y = make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x, y := ReadInt2()
		X[i], Y[i] = x, y
	}

	l, r, u, d := 0, 0, 0, 0
	for i := 0; i < n; i++ {
		x, y := X[i], Y[i]

		if x <= sx-1 {
			l++
		}
		if x >= sx+1 {
			r++
		}
		if y <= sy-1 {
			d++
		}
		if y >= sy+1 {
			u++
		}
	}

	maxi := Max(l, r, u, d)
	fmt.Println(maxi)
	if l == maxi {
		fmt.Println(sx-1, sy)
	} else if r == maxi {
		fmt.Println(sx+1, sy)
	} else if u == maxi {
		fmt.Println(sx, sy-1)
	} else {
		fmt.Println(sx, sy+1)
	}
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
- MOD取る系はint64必須ですよ？
*/

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

/*******************************************************************/

package main

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

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

// 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...)
}

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

// 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
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// 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 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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	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)
}

func main() {
	defer Flush()

	n := readi()
	sx := readi()
	sy := readi()
	var u, d, r, l int
	for i := 0; i < n; i++ {
		x := readi()
		y := readi()
		if x < sx {
			l++
		}
		if sx < x {
			r++
		}
		if y < sy {
			d++
		}
		if sy < y {
			u++
		}
	}
	a := make([][2]int, 4)
	dx := []int{-1, 0, 1, 0}
	dy := []int{0, -1, 0, 1}
	a[0][0] = l
	a[0][1] = 0
	a[1][0] = d
	a[1][1] = 1
	a[2][0] = r
	a[2][1] = 2
	a[3][0] = u
	a[3][1] = 3
	sort.Slice(a, func(i, j int) bool { return a[i][0] > a[j][0] })
	i := a[0][1]
	println(sx+dx[i], sy+dy[i])
}


package main
import(
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func main(){
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	nm := strings.Split(scanner.Text()," ")
	scanner.Scan()
	a := strings.Split(scanner.Text()," ")
	scanner.Scan()
	b := strings.Split(scanner.Text()," ")
	demA := 0
	// demB := 0
	n,_ := strconv.Atoi(nm[0])
	m,_ := strconv.Atoi(nm[1])
	for i := 0; i < m; i++{
		if demA == n{
			break
		}
		intB,_ := strconv.Atoi(b[i])
		intA,_ := strconv.Atoi(a[demA])
		if intB >= intA{
			demA += 1
		}
		// demB += 1
	}
	fmt.Println(n - demA)
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    a, b := make([]int,n), make([]int,m)
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }
    for i := 0; i < m; i++ { fmt.Scan(&b[i]) }
    sort.Ints(a)
    sort.Ints(b)
    ib, ans := 0, 0
    for ia := 0; ia < n; ia++ {
        if ib >= m {
            ans++
        } else {
            for b[ib] < a[ia] {
                ib++
                if ib == m { ans++; break }
            }
            ib++
        }
    }
    fmt.Println(ans)
}

package main
import (
	"fmt"
	//"bufio"
	//"os"
	//"strconv"
)

func main() {
	var n,m,i,j int
	fmt.Scan(&n,&m)
	a:=make([]int,n)
	b:=make([]int,m)
	for i=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	for i=0;i<m;i++ {
		fmt.Scan(&b[i])
	}
	for i,j=0,0; i<n && j<m;j++ {
		if b[j]>=a[i] {
			i++
		}
	}
	n-=i
	fmt.Println(n)
}

package main

import (
	"fmt"
)

func main() {

	var (
		n, m, i, j int32
		a, b       [3006]int32
	)

	fmt.Scan(&n)
	fmt.Scan(&m)
	for i = 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i = 0; i < m; i++ {
		fmt.Scan(&b[i])
	}

	i, j = 0, 0
	for i < n && j < m {
		if a[i] <= b[j] {
			i, j = i+1, j+1
		} else {
			j = j + 1
		}

	}

	fmt.Println(n - i)

}

// 387B-mic
package main

import (
	"fmt"
)

func main() {
	var n, m int					// variabel n, m dengan jenis int
	var a, b [3005]int				// variabel a dan b [3005] jenis int
	fmt.Scan(&n, &m)				// mengambil input
	for i := 0; i < n; i++ {		// looping
		fmt.Scan(&a[i])				// mengambil input
	}
	for i := 0; i < m; i++ {		// looping kedua
		fmt.Scan(&b[i])				// mengambil input
	}
	be := n							// variabel be diisi dengan n
	if be > m {						// jika be lebih dari m
		be = m					    // be sama dengan m
	}
	for i := be; i >= 0; i-- {		// looping ketiga
		ok := true					// variabel ok diisi dengan true
		for j := 0; j < i; j++ {	// looping keempat
			if a[j] > b[m-i+j] {	// jika a[j] lebih dari  b[m-i+j]
				ok = false			// ok sama dengan false
			}
		}
		if ok {						// jika ok
			fmt.Println(n - i)		//cetak hasil n - i
			return					// kembali ke fungsi awal
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(required []int, have []int, lenR int, lenH int) int {
	i, j := 0, 0

	for i < lenH {
		for j < lenR && i < lenH && required[j] > have[i] {
			i++
		}
		if j < lenR && i < lenH && required[j] <= have[i] {
			j++
		}
		i++
	}

	return lenR - j
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, m int

	fmt.Fscanf(r, "%d %d\n", &n, &m)

	required := make([]int, n)
	have := make([]int, m)

	for i := range required {
		if i == n-1 {
			fmt.Fscanf(r, "%d\n", &required[i])
		} else {
			fmt.Fscanf(r, "%d", &required[i])
		}
	}

	for i := range have {
		fmt.Fscanf(r, "%d ", &have[i])
	}

	fmt.Fprintf(os.Stdout, "%d\n", solve(required, have, n, m))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(required []int, have []int, lenR int, lenH int) int {
	i, j := 0, 0

	for i < lenH {
		if j < lenR && i < lenH && required[j] <= have[i] {
			j++
		}
		i++
	}

	return lenR - j
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, m int

	fmt.Fscanf(r, "%d %d\n", &n, &m)

	required := make([]int, n)
	have := make([]int, m)

	for i := range required {
		if i == n-1 {
			fmt.Fscanf(r, "%d\n", &required[i])
		} else {
			fmt.Fscanf(r, "%d", &required[i])
		}
	}

	for i := range have {
		fmt.Fscanf(r, "%d ", &have[i])
	}

	fmt.Fprintf(os.Stdout, "%d\n", solve(required, have, n, m))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(required []int, have []int, n int, m int) int {
	i, j := 0, 0

	for i < m {
		for j < n && i < m-1 && required[j] > have[i] {
			i++
		}
		if j < n && i < m && required[j] <= have[i] {
			j++
		}
		i++
	}

	return n - j
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, m int

	fmt.Fscanf(r, "%d %d\n", &n, &m)

	required := make([]int, n)
	have := make([]int, m)

	for i := range required {
		if i == n-1 {
			fmt.Fscanf(r, "%d\n", &required[i])
		} else {
			fmt.Fscanf(r, "%d", &required[i])
		}
	}

	for i := range have {
		fmt.Fscanf(r, "%d ", &have[i])
	}

	fmt.Fprintf(os.Stdout, "%d\n", solve(required, have, n, m))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(required []int, have []int, lenR int, lenH int) int {
	j := 0

	for i := 0; i < lenH; i++ {
		if j < lenR && i < lenH && required[j] <= have[i] {
			j++
		}
	}

	return lenR - j
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, m int

	fmt.Fscanf(r, "%d %d\n", &n, &m)

	required := make([]int, n)
	have := make([]int, m)

	for i := range required {
		if i == n-1 {
			fmt.Fscanf(r, "%d\n", &required[i])
		} else {
			fmt.Fscanf(r, "%d", &required[i])
		}
	}

	for i := range have {
		fmt.Fscanf(r, "%d ", &have[i])
	}

	fmt.Fprintf(os.Stdout, "%d\n", solve(required, have, n, m))
}

// 387B-mic
package main

import (
    "fmt"
)

func main() {
    var n, m int
    var a, b [3005]int
    fmt.Scan(&n, &m)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    for i := 0; i < m; i++ {
        fmt.Scan(&b[i])
    }
    be := n
    if be > m {
        be = m
    }
    for i := be; i >= 0; i-- {
        ok := true
        for j := 0; j < i; j++ {
            if a[j] > b[m-i+j] {
                ok = false
            }
        }
        if ok {
            fmt.Println(n - i)
            return
        }
    }
}

//http://codeforces.com/problemset/problem/387/B

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := NewStdReader(os.Stdin)
	n, m := reader.ReadInt(), reader.ReadInt()

	a := make([]int, 3000)
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
	}

	ai := 0
	for i := 0; i < m; i++ {
		b := reader.ReadInt()
		if b >= a[ai] {
			ai++
			if ai == n {
				fmt.Print(0)
				return
			}
		}
	}

	c := n - ai
	fmt.Print(c)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    a, b := make([]int,n), make([]int,m)
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }
    for i := 0; i < m; i++ { fmt.Scan(&b[i]) }
    sort.Ints(a)
    sort.Ints(b)
    ib, ans := 0, 0
    for ia := 0; ia < n; ia++ {
        if ib == m {
            ans++
        } else {
            for b[ib] < a[ia] {
                ib++
                if ib == m { ans++; break }
            }
        }
    }
    fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(required []int, have []int, lenR int, lenH int) int {
	i, j := 0, 0

	for i < lenH {
		for i < lenH && required[j] > have[i] {
			i++
		}
		if j < lenR-1 && i < lenH && required[j] <= have[i] {
			j++
		}
		i++
	}

	return lenR - j
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n, m int

	fmt.Fscanf(r, "%d %d\n", &n, &m)

	required := make([]int, n)
	have := make([]int, m)

	for i := range required {
		if i == n-1 {
			fmt.Fscanf(r, "%d\n", &required[i])
		} else {
			fmt.Fscanf(r, "%d", &required[i])
		}
	}

	for i := range have {
		fmt.Fscanf(r, "%d ", &have[i])
	}

	fmt.Fprintf(os.Stdout, "%d\n", solve(required, have, n, m))
}

// 387B-mic
package main

import (
    "fmt"
)

func main() {
    var n, m int
    var a, b [3005]int
    fmt.Scan(&n, &m)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    for i := 0; i < m; i++ {
        fmt.Scan(&b[i])
    }
    be := n
    if be > m {
        be = m
    }
    for i := be; i >= 0; i-- {
        ok := true
        for j := 0; j < i; j++ {
            if a[j] > b[m-i+j] {
                ok = false
            }
            if ok {
                fmt.Println(n - i)
                return
            }
        }
    }
}

//http://codeforces.com/problemset/problem/387/B

package main

import (
	"bufio"
	"io"
	"os"
	"fmt"
)

func main() {
	reader := NewStdReader(os.Stdin)
	n, m := reader.ReadInt(), reader.ReadInt()

	a := map[int]bool{}
	for i := 0; i < n; i++ {
		a[reader.ReadInt()] = false
	}

	for i := 0; i < m; i++ {
		a[reader.ReadInt()] = true
	}

	c := 0
	for _, v := range a {
		if !v {
			c++
		}
	}
	fmt.Print(c)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

//http://codeforces.com/problemset/problem/387/B

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := NewStdReader(os.Stdin)
	n, m := reader.ReadInt(), reader.ReadInt()

	a := make([]int, 3000)
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
	}

	ai := 0
	for i := 0; i < m; i++ {
		b := reader.ReadInt()
		if b >= a[ai] {
			ai++
			if ai == n-1 {
				fmt.Print(0)
				return
			}
		}
	}

	c := n - ai
	fmt.Print(c)
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 2*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 512*1024), 512*1024)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	s := scanner.Text()
	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] <= i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		var k int
		for k = 0; k < len(t[i]) && t[i][k] < j; k++ {
		}
		for ; k < len(t[i]); k++ {
			res += string(i + 97)
			for f := j; f < t[i][k]; f++ {
				buffer = append(buffer, int(s[f])-97)
			}
			j = t[i][k] + 1
		}
	}
	for i := range buffer {
		res += string(buffer[len(buffer)-1-i] + 97)
	}
	fmt.Println(res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 512*1024), 512*1024)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	s := scanner.Text()
	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] <= i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		var k int
		for k = 0; k < len(t[i]) && t[i][k] < j; k++ {
		}
		for ; k < len(t[i]); k++ {
			res += string(i + 97)
			for f := j; f < t[i][k]; f++ {
				buffer = append(buffer, int(s[f])-97)
			}
			j = t[i][k] + 1
		}
	}
	for q := range buffer {
		res += string(buffer[len(buffer)-1-q] + 97)
	}
	fmt.Println(res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 512*1024), 512*1024)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	s := scanner.Text()
	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] <= i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		cur := getMin(t[i], j)
		for cur != -1 {
			res += string(i + 97)
			for k := j; k < cur; k++ {
				buffer = append(buffer, int(s[k])-97)
			}
			j = cur + 1
			cur = getMin(t[i], j)
		}
	}
	for i := range buffer {
		res += string(buffer[len(buffer)-1-i] + 97)
	}
	fmt.Println(res)
}

func getMin(x []int, min int) int {
	if len(x) == 0 {
		return -1
	}
	l := 0
	r := len(x) - 1
	for l < r {
		mid := (l + r) / 2
		if x[mid] < min {
			l = mid + 1
		} else {
			r = mid
		}
	}
	if x[l] < min {
		return -1
	}
	return x[l]
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	a := readString()
	b := []byte(a)
	N := len(a)
	suffix := make([]byte, N)
	suffix[N-1] = b[N-1]
	for i := N - 2; i >= 0; i-- {
		if b[i] < suffix[i+1] {
			suffix[i] = b[i]
		} else {
			suffix[i] = suffix[i+1]
		}
	}
	res := make([]byte, 0)
	buf := make([]byte, 0)
	for i := 0; i < N; i++ {
		if b[i] <= suffix[i] {
			for len(buf) > 0 && (buf[len(buf)-1] <= b[i]) {
				res = append(res, buf[len(buf)-1])
				buf = buf[:len(buf)-1]
			}
			res = append(res, b[i])
		} else {
			for len(buf) > 0 && (buf[len(buf)-1] < b[i] && buf[len(buf)-1] <= suffix[i]) {
				res = append(res, buf[len(buf)-1])
				buf = buf[:len(buf)-1]
			}
			buf = append(buf, b[i])
		}
	}
	for i := 0; i < len(buf); i++ {
		res = append(res, buf[len(buf)-i-1])
	}
	fmt.Println(string(res))
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

type ByLen []string

func (a ByLen) Len() int           { return len(a) }
func (a ByLen) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByLen) Less(i, j int) bool { return len(a[i]) > len(a[j]) }

package main

import (
	"fmt"
)

func main() {
	totalLen, counterResult, counterTotal, counterCompare := 0,0,0,0
	inputString := ""
	e := []byte{124}
	fmt.Scanf("%s", &inputString)
	totalLen = len(inputString)

	compareString := make([]byte, totalLen+1, totalLen+1)
	resultString := make([]byte, totalLen+1, totalLen+1)

	compareString[totalLen] = e[0]

	for i := totalLen -1;i>-1; i-- {
		compareString[i] = min(compareString[i + 1], inputString[i])
	}

	for counterTotal < totalLen {
		if len(inputString)< counterCompare || len(resultString)< counterResult {
			break
		}
		resultString[counterResult] = inputString[counterCompare]
		counterResult++
		counterCompare++
		for counterResult >0 && resultString[counterResult-1] <= compareString[counterCompare] {
			//fmt.Print("in")
			counterResult--
			fmt.Print(string(resultString[counterResult]))
			counterTotal++
		}
	}
	fmt.Print("\n")
}

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

package main

import (
	"fmt"
)

func main() {
	totalLen, counterResult, counterTotal, counterCompare := 0,0,0,0
	inputString := ""
	compareString := [100001]byte{}
	resultString := [100001]byte{}
	e := []byte{124}
	fmt.Scanf("%s", &inputString)
	totalLen = len(inputString)
	compareString[totalLen] = e[0]

	for i := totalLen -1;i>-1; i-- {
		compareString[i] = min(compareString[i + 1], inputString[i])
	}

	for counterTotal < totalLen {
		if len(inputString)< counterCompare || len(resultString)< counterResult {
			break
		}
		resultString[counterResult] = inputString[counterCompare]
		counterResult++
		counterCompare++
		for counterResult >0 && resultString[counterResult-1] <= compareString[counterCompare] {
			//fmt.Print("in")
			counterResult--
			fmt.Print(string(resultString[counterResult]))
			counterTotal++
		}
	}
	fmt.Print("\n")
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	// fmt.Println(getMin([]int{0,4}, 0))
	s := scanner.Text()

	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] <= i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		cur := getMin(t[i], j)
		for cur != -1 {
			res += string(i + 97)
			for k := j; k < len(s) && k < cur; k++ {
				buffer = append(buffer, int(s[k])-97)
			}
			j = cur + 1
			cur = getMin(t[i], j)
		}
	}
	for i := range buffer {
		res += string(buffer[len(buffer)-1-i] + 97)
	}
	fmt.Println(res)
}

func getMin(x []int, min int) int {
	if len(x) == 0 {
		return -1
	}
	l := 0
	r := len(x) - 1
	for l < r {
		mid := (l + r) / 2
		if x[mid] < min {
			l = mid + 1
		} else {
			r = mid
		}
	}
	if x[l] < min {
		return -1
	}
	return x[l]
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	// fmt.Println(getMin([]int{0,4}, 0))
	s := scanner.Text()

	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] <= i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		cur := getMin(t[i], j)
		for cur != -1 {
			for k := j; k < len(s) && k < cur; k++ {
				buffer = append(buffer, int(s[k])-97)
			}
			res += string(i + 97)
			j = cur + 1
			cur = getMin(t[i], j)
		}
	}
	for i := range buffer {
		res += string(buffer[len(buffer)-1-i] + 97)
	}
	fmt.Println(res)
}

func getMin(x []int, min int) int {
	if len(x) == 0 {
		return -1
	}
	l := 0
	r := len(x) - 1
	for l < r {
		mid := (l + r) / 2
		if x[mid] < min {
			l = mid + 1
		} else {
			r = mid
		}
	}
	if x[l] < min {
		return -1
	}
	return x[l]
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	// fmt.Println(getMin([]int{0,4}, 0))
	s := scanner.Text()

	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] == i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		cur := getMin(t[i], j)
		for cur != -1 {
			for k := j; k < len(s) && k < cur; k++ {
				buffer = append(buffer, int(s[k])-97)
			}
			res += string(i + 97)
			j = cur + 1
			cur = getMin(t[i], j)
		}
	}
	for i := range buffer {
		res += string(buffer[len(buffer)-1-i] + 97)
	}
	fmt.Println(res)
}

func getMin(x []int, min int) int {
	if len(x) == 0 {
		return -1
	}
	l := 0
	r := len(x) - 1
	for l < r {
		mid := (l + r) / 2
		if x[mid] < min {
			l = mid + 1
		} else {
			r = mid
		}
	}
	if x[l] < min {
		return -1
	}
	return x[l]
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()

	// fmt.Println(getMin([]int{0,4}, 0))
	s := scanner.Text()

	t := make([][]int, 26)
	res := ""
	buffer := []int{}

	for i, el := range s {
		t[el-97] = append(t[el-97], i)
	}

	j := 0
	for i := 0; i < 26; i++ {
		for len(buffer) != 0 && buffer[len(buffer)-1] <= i {
			res += string(buffer[len(buffer)-1] + 97)
			buffer = buffer[0 : len(buffer)-1]
		}
		cur := getMin(t[i], j)
		for cur != -1 {
			res += string(i + 97)
			for k := j; k < cur; k++ {
				buffer = append(buffer, int(s[k])-97)
			}
			j = cur + 1
			cur = getMin(t[i], j)
		}
	}
	for i := range buffer {
		res += string(buffer[len(buffer)-1-i] + 97)
	}
	fmt.Println(res)
}

func getMin(x []int, min int) int {
	if len(x) == 0 {
		return -1
	}
	l := 0
	r := len(x) - 1
	for l < r {
		mid := (l + r) / 2
		if x[mid] < min {
			l = mid + 1
		} else {
			r = mid
		}
	}
	if x[l] < min {
		return -1
	}
	return x[l]
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	a := readString()
	b := []byte(a)
	suffix := make([]byte, len(a))
	suffix[len(suffix)-1] = b[len(suffix)-1]
	for i := len(suffix) - 2; i >= 0; i-- {
		if b[i] < suffix[i+1] {
			suffix[i] = b[i]
		} else {
			suffix[i] = suffix[i+1]
		}
	}
	res := make([]byte, 0)
	buf := make([]byte, 0)
	for i := 0; i < len(b); i++ {
		if b[i] <= suffix[i] {
			res = append(res, b[i])
		} else {
			buf = append(buf, b[i])
		}
	}
	for i := 0; i < len(buf); i++ {
		res = append(res, buf[len(buf)-i-1])
	}
	fmt.Println(string(res))
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

type ByLen []string

func (a ByLen) Len() int           { return len(a) }
func (a ByLen) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByLen) Less(i, j int) bool { return len(a[i]) > len(a[j]) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	a := readString()
	b := []byte(a)
	N := len(a)
	suffix := make([]byte, N)
	suffix[N-1] = b[N-1]
	for i := N - 2; i >= 0; i-- {
		if b[i] < suffix[i+1] {
			suffix[i] = b[i]
		} else {
			suffix[i] = suffix[i+1]
		}
	}
	res := make([]byte, 0)
	buf := make([]byte, 0)
	for i := 0; i < N; i++ {
		if b[i] <= suffix[i] {
			for len(buf) > 0 && buf[len(buf)-1] <= b[i] {
				res = append(res, buf[len(buf)-1])
				buf = buf[:len(buf)-1]
			}
			res = append(res, b[i])
		} else {
			buf = append(buf, b[i])
		}
	}
	for i := 0; i < len(buf); i++ {
		res = append(res, buf[len(buf)-i-1])
	}
	fmt.Println(string(res))
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

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

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

type ByLen []string

func (a ByLen) Len() int           { return len(a) }
func (a ByLen) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByLen) Less(i, j int) bool { return len(a[i]) > len(a[j]) }

package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	s := "acdb"
	str := strings.Split(s, "")
	sort.Strings(str)
	fmt.Println(strings.Join(str, ""))
}

package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	s := ""
	fmt.Scanf("%s", &s)
	str := strings.Split(s, "")
	sort.Strings(str)
	fmt.Println(strings.Join(str, ""))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func reverse(numbers []int, m int) {
	for i, j := 0, m-1; i < j; i, j = i+1, j-1 {
		numbers[i], numbers[j] = numbers[j], numbers[i]
	}
}

func dp(f []int, value []int, m int) {
	v := make([]int, m+1)
	for i := range v {
		v[i] = 2147483647
	}
	v[0] = 0

	for i := 0; i < m; i++ {
		f[i] = sort.Search(len(v), func(k int) bool { return v[k] > value[i] })
		if v[f[i]] > value[i] {
			v[f[i]] = value[i]
		}
	}
}

func main() {
	in.Split(bufio.ScanWords)
	n := readInt()
	m := readInt()
	value := make([]int, m+1)
	for i := 0; i < n; i++ {
		x := readInt()
		y := readInt()
		value[x-1]++
		value[y]--
	}

	for i := 1; i < m; i++ {
		value[i] += value[i-1]
	}

	f1 := make([]int, m)
	dp(f1, value, m)

	reverse(value, m)

	f2 := make([]int, m)
	dp(f2, value, m)

	ans := 0
	for i := 0; i < m; i++ {
		now := f1[i] + f2[m-i-1] - 1
		if ans < now {
			ans = now
		}
	}

	fmt.Printf("%d\n", ans)
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
	"sort"
)

func binarySearch(a []int, target, left, right int) int {
	if left > right {
		return -1
	} else {
		mid := (left + right) / 2
		if a[mid] <= target {
			return binarySearch(a, target, mid + 1, right)
		} else {
			ans := binarySearch(a, target, left, mid - 1)
			if ans != -1 {
				return ans
			} else {
				return mid
			}
		}
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	l := make([]int, n)
	r := make([]int, n)
	seg := make([]int, m)
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%d %d\n", &l[i], &r[i])
		l[i] --
		r[i] --
	}
	sort.Ints(l)
	sort.Ints(r)

	count, lp, rp := 0, 0, 0
	for i := 0;i < m;i ++ {
		for ;lp < n && l[lp] == i;lp ++ {
			count ++
		}
		seg[i] = count
		for ;rp < n && r[rp] == i; rp ++ {
			count --
		}
	}

	leftdp := make([]int, m)
	rightdp := make([]int, m)
	leftstack := make([]int, 0, n)
	rightstack := make([]int, 0, n)
	for i := 0;i < m;i ++ {
		if len(leftstack) == 0 || seg[i] >= leftstack[len(leftstack) - 1] {
			leftstack = append(leftstack, seg[i])
			leftdp[i] = len(leftstack)
		} else {
			pos := binarySearch(leftstack, seg[i], 0, len(leftstack) - 1)
			leftstack[pos] = seg[i]
			leftdp[i] = pos + 1
		}
	}

	for i := m - 1;i >= 0;i -- {
		if len(rightstack) == 0 || seg[i] >= rightstack[len(rightstack) - 1] {
			rightstack = append(rightstack, seg[i])
			rightdp[i] = len(rightstack)
		} else {
			pos := binarySearch(rightstack, seg[i], 0, len(rightstack) - 1)
			rightstack[pos] = seg[i]
			rightdp[i] = pos + 1
		}
	}

	max := -1
	for i := 0;i < m;i ++ {
		if leftdp[i] + rightdp[i] - 1 > max {
			max = leftdp[i] + rightdp[i] - 1
		}
	}
	fmt.Printf("%d", max)

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func maxNonDec(seq []int) []int {
	ret := make([]int, len(seq)+1)
	m := make([]int, len(seq)+1)
	for i := 1; i < len(m); i++ {
		m[i] = math.MaxInt32
	}
	for i := range seq {
		lo := 0
		hi := i
		for lo < hi {
			mi := (lo + hi + 1) / 2
			if m[mi] <= seq[i] {
				lo = mi
			} else {
				hi = mi - 1
			}
		}
		ret[i+1] = ret[i]
		if ret[i+1] < lo+1 {
			ret[i+1] = lo + 1
		}
		if m[lo+1] > seq[i] {
			m[lo+1] = seq[i]
		}
	}
	return ret
}

func main() {
	in.Split(bufio.ScanWords)

	n := readInt()
	m := readInt()
	start := make([]int, n)
	end := make([]int, n)
	for i := range start {
		start[i] = readInt() - 1
		end[i] = readInt()
	}
	sort.Ints(start)
	sort.Ints(end)
	seq := make([]int, m)
	cur := 0
	for i := range seq {
		for len(start) > 0 && start[0] == i {
			cur++
			start = start[1:]
		}
		for len(end) > 0 && end[0] == i {
			cur--
			end = end[1:]
		}
		seq[i] = cur
	}

	pref := maxNonDec(seq)
	for i := range seq[:m/2] {
		seq[i], seq[m-1-i] = seq[m-1-i], seq[i]
	}
	suff := maxNonDec(seq)

	ans := 0
	for i := range pref {
		if cur := pref[i] + suff[m-i]; ans < cur {
			ans = cur
		}
	}
	fmt.Println(ans)
}


// Author: sighduck
// URL: https://codeforces.com/contest/1272/problem/A

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func Solve(a, b, c int) int {
	arr := []int{a, b, c}
	sort.Ints(arr)
	if arr[0] == arr[2] || arr[0]+1 == arr[2] {
		return 0
	}
	return 2 * (arr[2] - arr[0] - 2)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0; i < q; i++ {
		var a, b, c int
		fmt.Fscanf(reader, "%d %d %d\n", &a, &b, &c)
		fmt.Fprintf(writer, "%d\n", Solve(a, b, c))
	}
}

/*
*In The Name of God
*
* +===============================================
* | Author:        Mohammad Fatemi <mr.smf8@gmail.com>
* |
* | Creation Date: 29-02-2020
* |
* | File Name:     p7.go
* +===============================================
 */

// https://codeforces.com/contest/1272/problem/A
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)

func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	var q int
	scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		var a, b, c float64
		scanf("%f %f %f\n", &a, &b, &c)
		ans := math.Inf(1)
		for i := -1; i <= 1; i++ {
			for j := -1; j <= 1; j++ {
				for k := -1; k <= 1; k++ {
					ta, tb, tc := (a + float64(i)), (b + float64(j)), (c + float64(k))
					sum := math.Abs(ta-tb) + math.Abs(ta-tc) + math.Abs(tc-tb)
					ans = math.Min(ans, sum)
				}
			}
		}
		fmt.Println(int(ans))
	}
}

package main

import (
	"fmt"
	"math"
	"sort"
)

var q, a, b, c int

func main() {
	_, _ = fmt.Scan(&q)
	for q > 0 {
		_, _ = fmt.Scan(&a)
		_, _ = fmt.Scan(&b)
		_, _ = fmt.Scan(&c)
		q--
		fmt.Printf("%0.f\n", f(a, b, c))
	}
}

func f(a, b, c int) float64 {
	ar := []int{a, b, c}
	sort.Ints(ar)
	a = ar[0]
	b = ar[1]
	c = ar[2]
	if math.Abs(float64(a-b)) <= 1 && math.Abs(float64(b-c)) <= 1 {
		return 0
	}
	if a < b && b < c {
		a++
		c--
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	if b == c && b != a {
		a++
		b--
		c--
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	if a == b && b != c {
		c--
		a++
		b++
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	return 0
}

// @problemURL url.com
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

// var inFile, _ = os.Open("in.txt")
// var outFile, _ = os.OpenFile("out.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
// var in = bufio.NewReader(inFile)
// var out = bufio.NewWriter(outFile)

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { _, _ = fmt.Fprintf(out, f, a...) }
func scanf(f string, a ...interface{})  { _, _ = fmt.Fscanf(in, f, a...) }

func cleanup() {
	_ = out.Flush()
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

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

func main() {
	defer cleanup()
	var q int
	scanf("%d\n", &q)
	for qq := 0; qq < q; qq++ {
		s := make([]int, 3)
		scanf("%d %d %d\n", &s[0], &s[1], &s[2])
		sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })

		// fmt.Println(s)
		ans := 2 * min(min(s[2]-s[0], abs(s[2]-s[0]-1)), abs(s[2]-s[0]-2))

		printf("%d\n", ans)
	}
}

// TODO Try without cleanup => Try on codeforces
// TODO ReadString without delim at the end

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var q int
var a, b, c int64

func main() {
	q = ReadInt()

	for tc := 0; tc < q; tc++ {
		a, b, c = ReadInt64_3()

		solve()
	}
}

func solve() {
	A := LongInt{a, b, c}
	sort.Sort(A)

	// aa, bb, cc := A[0], A[1], A[2]
	// if aa < bb {
	// 	aa++
	// }
	// if bb < cc {
	// 	cc--
	// }

	// ans := int64(0)
	// ans += AbsInt(bb - aa)
	// ans += AbsInt(cc - bb)
	// ans += AbsInt(cc - aa)

	aa, _, cc := A[0], A[1], A[2]
	if aa < cc {
		aa++
	}
	if aa < cc {
		cc--
	}
	ans := 2 * (cc - aa)

	fmt.Println(ans)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

type LongInt []int64

func (a LongInt) Len() int           { return len(a) }
func (a LongInt) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a LongInt) Less(i, j int) bool { return a[i] < a[j] }

// S := LongInt{'a', 'b', 'c'}
// sort.Sort(S) or sort.Sort(sort.Reverse(S))

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
*/

/*******************************************************************/

package main

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

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

// 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
}

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

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return 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...)
}

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

// 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 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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	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)
}

func main() {
	defer Flush()

	q := readi()
	for i := 0; i < q; i++ {
		a := readi()
		b := readi()
		c := readi()
		println(solve(a, b, c))
	}
}

func solve(a, b, c int) int {
	x := max(a, max(b, c))
	i := min(a, min(b, c))
	return max((x-i-2)*2, 0)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n, min, a, b, c, dist, i int64
	fmt.Fscanf(reader, "%d\n", &n)
	for i = 1; i <= n; i++ {
		fmt.Fscanf(reader, "%d %d %d\n", &a, &b, &c)
		min = math.MaxInt64
		p := []int64{a - 1, a, a + 1}
		q := []int64{b - 1, b, b + 1}
		r := []int64{c - 1, c, c + 1}
		for _, a1 := range p {
			for _, b1 := range q {
				for _, c1 := range r {
					dist = abs(a1-b1) + abs(a1-c1) + abs(b1-c1)
					if min > dist {
						min = dist
					}
					//fmt.Println(abs(a1-b1), abs(a1-c1), abs(b1-c1), dist, min)
				}
			}
		}
		fmt.Fprintf(writer, "%d\n", min)
	}
}

/*
*In The Name of God
*
* +===============================================
* | Author:        Mohammad Fatemi <mr.smf8@gmail.com>
* |
* | Creation Date: 29-02-2020
* |
* | File Name:     p7.go
* +===============================================
 */

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)

func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	var q int
	scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		var a, b, c int
		scanf("%d %d %d\n", &a, &b, &c)
		a, b, c = sort(a, b, c)
		var ab, bc, ac int
		ab = 0
		bc = 0
		if a-b > 0 {
			ab = a - b - 1
			a--
		}
		if b-c > 0 {
			bc = b - c - 1
			c++
		}
		ac = (a - c)
		fmt.Println((ab + ac + bc))
	}
}

func sort(a, b, c int) (int, int, int) {
	r1 := math.Max(float64(a), math.Max(float64(b), float64(c)))
	r3 := math.Min(float64(a), math.Max(float64(b), float64(c)))
	r2 := float64(a+b+c) - r1 - r3
	return int(r1), int(r2), int(r3)
}

package main

import (
	"fmt"
	"math"
	"sort"
)

var q, a, b, c int

func main() {
	_, _ = fmt.Scan(&q)
	for q > 0 {
		_, _ = fmt.Scan(&a)
		_, _ = fmt.Scan(&b)
		_, _ = fmt.Scan(&c)
		q--
		fmt.Printf("%0.f\n", f(a, b, c))
	}
}

func f(a, b, c int) float64 {
	ar := []int{a, b, c}
	sort.Ints(ar)
	a = ar[0]
	b = ar[1]
	c = ar[2]
	if math.Abs(float64(a-b)) <= 1 && math.Abs(float64(b-c)) <= 1 {
		return 0
	}
	if a < b && b < c {
		a++
		c--
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	if b == c && b != a {
		a++
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	if a == b && b != c {
		c--
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	return 0
}

package main

import (
	"fmt"
	"math"
	"sort"
)

var q, a, b, c int

func main() {
	_, _ = fmt.Scan(&q)
	for q > 0 {
		_, _ = fmt.Scan(&a)
		_, _ = fmt.Scan(&b)
		_, _ = fmt.Scan(&c)
		q--
		fmt.Printf("%v\n", f(a, b, c))
	}
}

func f(a, b, c int) float64 {
	ar := []int{a, b, c}
	sort.Ints(ar)
	a = ar[0]
	b = ar[1]
	c = ar[2]
	if math.Abs(float64(a-b)) <= 1 && math.Abs(float64(b-c)) <= 1 {
		return 0
	}
	if a < b && b < c {
		a++
		c--
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	if b == c && b != a {
		a++
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	if a == b && b != c {
		c--
		return math.Abs(float64(a-b)) + math.Abs(float64(a-c)) + math.Abs(float64(b-c))
	}
	return 0
}

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var x int
	fmt.Fscan(os.Stdin, &x)
	var v = []int{0, 0, 0}
	for i := 0; i < x; i++ {
		fmt.Fscan(os.Stdin, &v[0], &v[1], &v[2])
		sort.Ints(v)
		if v[0] < v[1] {
			v[0]++
		}
		if v[2] > v[1] {
			v[2]--
		}
		rez := v[2] - v[1] + v[2] - v[0] + v[1] - v[0]
		fmt.Println(rez)
	}
}


package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	var s string
	fmt.Scan(&s)
	cnt := make([]int, 26)
	for i := 0; i < N; i++ {
		c := s[i] - 'A'
		cnt[c]++
	}
	ans := N + N
	for i := 0; i < K; i++ {
		if cnt[i] < ans {
			ans = cnt[i]
		}
	}
	fmt.Println(ans * K)
}

package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)
	a := make([]int, k)
	for _, ch := range s {
		a[ch-'A'] += 1
	}
	min := a[0]
	for i := 1; i < k; i++ {
		if a[i] < min {
			min = a[i]
		}
	}
	fmt.Print(k * min)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

type Pair struct {
	first  int64
	second int
}

func main() {
	defer writer.Flush()
	var n, k int64
	scanf("%d %d\n", &n, &k)
	var s string
	scanf("%s", &s)

	count := [26]int64{}

	for i := 0; i < int(n); i++ {
		count[s[i]-'A']++
	}
	sofar := int64(9999999999)
	// pairs := make([]Pair, 26)
	for i := 0; i < int(k); i++ {
		sofar = min(sofar, count[i])
	}

	// sort.Slice(pairs, func(i, j int) bool {
	// 	if pairs[i].first > pairs[j].first {
	// 		return true
	// 	}
	// 	return false
	// })

	// for i := int64(0); i < 26; i++ {
	// 	if (i+1)*pairs[i].first > sofar {
	// 		sofar = (i + 1) * pairs[i].first
	// 	}
	// }
	printf("%d", sofar*k)

}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, k int

	fmt.Fscan(reader, &n, &k)
	var str string

	letters := make(map[string]int)
	fmt.Fscan(reader, &str)
	for _, key := range str {
		letters[string(key)]++
	}

	if len(letters) < k {
		fmt.Println(0)
		return
	}

	var mn int = math.MaxInt32
	for _, vl := range letters {
		if mn > vl {
			mn = vl
		}
	}

	fmt.Println(mn * k)

}

package main

import (
	"fmt"
)

func main() {
	n, k, s, aCode := 0, 0, "", "A"[0]
	fmt.Scan(&n, &k, &s)

	codeCount := make([]int, k)
	for i := 0; i < n; i++ {
		codeCount[s[i]-aCode]++
	}

	min := 100000
	for i := 0; i < k; i++ {
		if codeCount[i] < min {
			min = codeCount[i]
		}
	}

	fmt.Println(min * k)
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func Sol567D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n, k, sz, m int
	Fscan(in, &n, &k, &sz, &m)
	sz++
	x := make([]int, m)
	for i := range x {
		Fscan(in, &x[i])
	}

	ans := sort.Search(m+1, func(end int) bool {
		if end == 0 {
			return false
		}
		y := make([]int, end, end+1)
		copy(y, x)
		sort.Ints(y)
		y = append(y, n+1)
		cnt := y[0] / sz
		for i := 1; i <= end; i++ {
			cnt += (y[i] - y[i-1]) / sz
			if cnt >= k {
				return false
			}
		}
		return true
	})
	if ans == m+1 {
		ans = -1
	}
	Fprint(out, ans)
}

func main() {
	Sol567D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func Sol567D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n, k, sz, m int
	Fscan(in, &n, &k, &sz, &m)
	sz++
	x := make([]int, m)
	for i := range x {
		Fscan(in, &x[i])
	}

	ans := sort.Search(m+1, func(end int) bool {
		if end == 0 {
			return false
		}
		y := make([]int, end, end+1)
		copy(y, x)
		sort.Ints(y)
		y = append(y, n+1)
		cnt := y[0] / sz
		for i := 1; i <= end; i++ {
			cnt += (y[i] - y[i-1]) / sz
		}
		return cnt < k
	})
	if ans == m+1 {
		ans = -1
	}
	Fprint(out, ans)
}

func main() {
	Sol567D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func Sol567D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n, k, sz, m int
	Fscan(in, &n, &k, &sz, &m)
	sz++
	x := make([]int, m)
	for i := range x {
		Fscan(in, &x[i])
	}

	ans := sort.Search(m+1, func(end int) bool {
		if end == 0 {
			return false
		}
		y := make([]int, end)
		copy(y, x)
		sort.Ints(y)
		y = append(y, n+1)
		cnt := y[0] / sz
		for i := 1; i <= end; i++ {
			cnt += (y[i] - y[i-1]) / sz
			if cnt >= k {
				return false
			}
		}
		return true
	})
	if ans == m+1 {
		ans = -1
	}
	Fprint(out, ans)
}

func main() {
	Sol567D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func Sol567D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n, k, sz, m int
	Fscan(in, &n, &k, &sz, &m)
	x := make([]int, m)
	for i := range x {
		Fscan(in, &x[i])
	}

	ans := sort.Search(m+1, func(end int) bool {
		if end == 0 {
			return false
		}
		y := make([]int, end)
		copy(y, x)
		sort.Ints(y)
		y = append(y, n)
		cnt := (y[0] - 1) / sz
		for i := 1; i <= end; i++ {
			cnt += (y[i] - y[i-1]) / sz
			if cnt >= k {
				return false
			}
		}
		return true
	})
	if ans == m+1 {
		ans = -1
	}
	Fprint(out, ans)
}

func main() {
	Sol567D(os.Stdin, os.Stdout)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	s := readString(reader)

	res := solve(s)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const MOD = 998244353

func modAdd(a, b int) int {
	a += b
	if a >= MOD {
		a -= MOD
	}
	return a
}

func solve(s string) int {
	dp := make([][][]int, 2)
	for i := 0; i < 2; i++ {
		dp[i] = make([][]int, 8)
		for j := 0; j < 8; j++ {
			dp[i][j] = make([]int, 8)
		}
	}
	dp[0][0][0] = 1

	n := len(s)

	for i := 1; i <= n; i++ {
		clear(dp[i&1])
		for mask1 := 0; mask1 < 8; mask1++ {
			for mask2 := 0; mask2 < 8; mask2++ {
				for m := 0; m < 8; m++ {
					var flag bool
					for j := 0; j < 3; j++ {
						if s[i-1] == '0' && (mask2>>j)&1 == 0 && (m>>j)&1 == 1 {
							flag = true
							break
						}
					}
					if flag {
						continue
					}
					tmp1 := mask1
					tmp2 := mask2

					for j := 0; j < 3; j++ {
						if int(s[i-1]-'0') != (m>>j)&1 {
							tmp2 |= 1 << j
						}
					}
					for j := 0; j < 3; j++ {
						if m == (1<<j) || m == 7-(1<<j) {
							tmp1 |= 1 << j
						}
					}
					dp[i&1][tmp1][tmp2] = modAdd(dp[i&1][tmp1][tmp2], dp[(i-1)&1][mask1][mask2])
				}
			}
		}
	}

	var ans int

	for i := 0; i < 8; i++ {
		ans = modAdd(ans, dp[n&1][7][i])
	}

	return ans
}

func clear(mat [][]int) {
	for i := 0; i < len(mat); i++ {
		for j := 0; j < len(mat[i]); j++ {
			mat[i][j] = 0
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	s := readString(reader)

	res := solve(s)

	fmt.Println(res)
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const MOD = 998244353

func modAdd(a, b int) int {
	a += b
	if a >= MOD {
		a -= MOD
	}
	return a
}

func solve(s string) int {
	dp := make([][][]int, len(s)+1)
	for i := 0; i <= len(s); i++ {
		dp[i] = make([][]int, 8)
		for j := 0; j < 8; j++ {
			dp[i][j] = make([]int, 8)
		}
	}
	dp[0][0][0] = 1

	n := len(s)

	for i := 1; i <= n; i++ {
		for mask1 := 0; mask1 < 8; mask1++ {
			for mask2 := 0; mask2 < 8; mask2++ {
				for m := 0; m < 8; m++ {

					var flag bool
					for j := 0; j < 3; j++ {
						if s[i-1] == '0' && (mask2>>j)&1 == 0 && (m>>j)&1 == 1 {
							flag = true
							break
						}
					}
					if flag {
						continue
					}
					tmp1 := mask1
					tmp2 := mask2

					for j := 0; j < 3; j++ {
						if int(s[i-1]-'0') != (m>>j)&1 {
							tmp2 |= 1 << j
						}
					}
					for j := 0; j < 3; j++ {
						if m == (1<<j) || m == 7-(1<<j) {
							tmp1 |= 1 << j
						}
					}
					dp[i][tmp1][tmp2] = modAdd(dp[i][tmp1][tmp2], dp[i-1][mask1][mask2])
				}
			}
		}
	}

	var ans int

	for i := 0; i < 8; i++ {
		ans = modAdd(ans, dp[n][7][i])
	}

	return ans
}