jiahuimbzuai/CoQuIR huggingface dataset:
//  [typescript]
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n: number = 0;
    let ans: number = 0;
    // init
    n = Number(input.shift());
    // solve
    ans = Math.floor((n + 1) / 2);
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();
//  [typescript]
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");

  const N = parseInt(input[0]);
  console.log(Math.floor((N + 1)  / 2));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  o.o(o.ceil(o.n()/2))
}
m();
//  [python]
w,a,b=map(int,input().split())
print(0 if b<=a<=b+w or a<=b<=a+w else min(abs(b-a-w),abs(a-b-w)))
//  [python]
w,a,b = map(int, raw_input().split())

def f(a,b,w):
	if a > b:
		return f(b,a,w)
	return max(0, b - (a + w))

print f(a, b,w)
//  [python]
def main():
    w, a, b = map(int, input().split())

    if a <= b <= a + w or a <= b + w <= a + w:
        print(0)
    elif b <= a <= b + w or b <= a + w <= b + w:
        print(0)
    else:
        print(min(abs(a + w - b), abs(b + w - a)))


if __name__ == "__main__":
    main()
//  [java]
import java.awt.AWTError;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		int aw = in[0] + in[1];
		int min = 0;
		if (aw < in[2]) 
			min = in[2] - aw;
		else if (in[0] >= in[1])
			min = 0;
		else if (aw > in[2])
			min = in[1] - (in[0] + in[2]);
		
		System.out.println(min);		
	}
}
//  [java]
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int min = 0;
		
		while(true){
			if (Math.abs(a-b) <= w){
				System.out.println(min);
				break;
			}else{
				min+=1;
				w++;
			}
		}
	}
}
//  [java]
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
class Main{
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            br.lines()
                .forEach(n -> met(n));
        }catch(Exception e){
        }
    }

    public void met(String n){
        String[] tmp = n.split(" ");
        Integer w = Integer.parseInt(tmp[0]);
        Integer a = Integer.parseInt(tmp[1]);
        Integer b = Integer.parseInt(tmp[2]);

        if(a <= b){
            if(a + w >= b)
                System.out.println(0);
            else
                System.out.println(b - (a + w));
        }
        else{
            if(b + w >= a)
                System.out.println(0);
            else
                System.out.println(a - (b + w));
        }
    }


    public static void main(String[] args){
        new Main().run();
    }
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll w, a, b;
  cin >> w >> a >> b;

  cout << max(max(a,b) - (min(a,b) + w), 0ll) << endl;

  return 0;
}
//  [cpp]
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int w, a, b, tmp;
  	cin >> w >> a >> b;
  	tmp = abs( a - b );
  	if( tmp <= w )
		cout << 0;
  	else cout << tmp - w;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  if(b >= a) cout << max(0, b-a-W) << endl;
  else cout << max(0, a-b-W) << endl;
}
//  [c]
#include <stdio.h>
int main(void){
    int w, a, b, move=0;
    scanf("%d%d%d", &w, &a, &b);
    if(a<b && (a+w)>=b) move=0;
    else if(a<b) move=b-(a+w);
    else if(a>b && (b+w)>=a) move=0;
    else if(a>b) move=a-(b+w);
    printf("%d", move);
    return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
        int a,b,w,s;
        scanf("%d%d%d",&w,&a,&b);

        s=a-b;
        if(s<0)s=-s;
        if(s<=w)printf("0\n");
        else printf("%d\n",s-w);
        return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int W, a, b;

    scanf("%d%d%d", &W, &a, &b);

    if(a+W < b){
        printf("%d\n", b - (a + W));
    }else if(a <= b){
        printf("0\n");
    }else if(a < b + W){
        printf("0\n");
    }else{
        printf("%d\n", a - (b + W));
    }

    return 0;
}
//  [javascript]
function Main(input) {
	var W = parseInt(input.split(" ")[0]);
	var a = parseInt(input.split(" ")[1]);
	var b = parseInt(input.split(" ")[2]);
 
	var ans;
 
	if ((b - a - W) > 0) {
		ans = b - a - W;
	} else if ((a - b - W) > 0) {
		ans = a - b - W;
	} else {
		ans = 0;
	}
 
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));process.stdin.resume();
//  [javascript]
const main = input => {
  const [W, a, b] = input.trim().split(' ').map(x => parseInt(x))
  if (a > b) {
    console.log(Math.max(a - (b + W), 0))
  } else if (a < b) {
    console.log(Math.max(b - (a + W), 0))
  } else {
    console.log(0)
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let W = Number(input[0].split(' ')[0])
	let a = Number(input[0].split(' ')[1])
	let b = Number(input[0].split(' ')[2])
	let dist = 0
	if(b <= a && b >= a + W) {
		console.log(0)
		return
	}
	if(b + W < a) {
		dist = a - (b + W)
	} else {
		dist = b - (a + W)
	}
	console.log(dist < 0 ? 0 : dist)

}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var w, a, b int
	fmt.Scan(&w, &a, &b)
	
	ans := 0
	if a + w < b {
		ans = b - (a + w)
	} else if b + w < a {
		ans = a - (b + w)
	} 
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	// Code for B - NarrowRectanglesEasy
	var W, a, b int
	fmt.Scanf("%d %d %d", &W, &a, &b)

	if a+W < b {
		fmt.Println(b - (a + W))
	} else if b+W < a {
		fmt.Println(a - (b + W))
	} else {
		fmt.Println("0")
	}
}
//  [go]
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
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
}

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	W, a, b := getInt(), getInt(), getInt()
	if a > b {
		a, b = b, a
	}
	out(max(0, b-(a+W)))
}
//  [ruby]
w,a,b = gets.chomp.split(' ').map(&:to_i)
if b-a-w >= 0
  puts b-a-w
elsif a-b-w >= 0
  puts a-b-w
else
  puts 0
end
//  [ruby]
w,a,b=gets.split.map &:to_i

if (a..a+w).include?(b)||(a..a+w).include?(b+w)
  p 0
  exit
end
p [(a+w-b).abs,(b+w-a).abs].min
//  [ruby]
w,a,b = gets.strip.split.map(&:to_i)
if a+w < b
  puts b-a-w
elsif b+w < a
  puts a-b-w
elsif
  puts 0
end
//  [rust]
use proconio::input;

fn main() {
    input! {
        w: i64,
        a: i64,
        b: i64,
    };
    let (b_l, b_r) = (b, b + w);
    let (a_l, a_r) = (a, a + w);
    let ans = if b_r < a_l {
        a_l - b_r
    } else if a_r < b_l {
        b_l - a_r
    } else {
        0
    };
    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        w: isize,
        a: isize,
        b: isize
    };
    use std::cmp::max;
    println!("{}", max(max(0, a - b - w), b - a - w));
}
//  [rust]
use proconio::input;

fn main() {
	input!(w: i32);
	input!(a: i32);
	input!(b: i32);

	let ans;
	let d = (b-a).abs();
	if d <= w {
		ans = 0;
	}
	else {
		ans = d - w;
	}
	println!("{}", ans);
}
//  [swift]
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (w, a, b) = toTuple(readInts())
let d = max(a, b) - (min(a, b) + w)
print(d < 0 ? 0 : d)
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [W, a, b] = input[0].map(Number);

  if ((b >= a && b <= a + W) || (b + W >= a && b + W <= a + W)) {
    return 0;
  }

  return Math.min(
    Math.abs(a - b),
    Math.abs(a - (b + W)),
    Math.abs(a + W - b),
    Math.abs(a + W - (b + W))
  );
};

console.log(main(read()));
//  [typescript]
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

const main = (input: string): void => {
  const [W, a, b] = input.split(" ").map((str) => Number(str));
  if ((a <= b && b <= a + W) || (b <= a && a <= b + W)) {
    console.log(0);
  } else if (b > a) {
    console.log(b - a - W);
  } else {
    console.log(a - b - W);
  }
};

main(input);
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [W, a, b] = input[0].map(Number);

  if (Math.abs(a - b) <= W) {
    return 0;
  }

  return Math.abs(a - b) - W;
};

console.log(main(read()));
//  [python]
n = int(input())
a = n % 10
b = (n // 10) % 10
c = n // 100
n = 100 * c + 10 * b + a

if c < b or c < a:
    print(100 * (c + 1) + 10 * (c + 1) + c +1)
else:
    print(100 * c + 10 * c + c)
//  [python]
N = int(input())
for i in range(1, 10):
    if N <= (i * 111):
        print(i * 111)
        break
//  [python]
N = int(input())

if N % 111 == 0:
    print(N)
else:
    print(((N // 111) + 1) * 111)
//  [python]
import numpy as np

N = int(input())
for i in range(1, 10):
    ii = i*111
    if ii >= N:
        print(ii)
        break
//  [python]
import numpy as np

n = int(input())

for i in range(1,10,1):
    if n <= i*111:
        ans = i*111
        break

print(ans)
//  [python]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    if len(sys.argv) == 1:
        set_stdin(os.path.dirname(__file__) + '/test/' + 'sample-1.in')# }}}

def solve():
    N = int(input())
    for n in range(N, 1112):
        s = set()
        for c in str(n):
            s.add(c)
        if len(s)==1:
            print(n)
            return 0
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}
//  [java]
import java.util.*;
import java.io.*;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		if(n <= 111) System.out.println(111);
		else if(n <= 222)System.out.println(222);
		else if(n <= 333)System.out.println(333);
		else if(n <= 444)System.out.println(444);
		else if(n <= 555)System.out.println(555);
		else if(n <= 666)System.out.println(666);
		else if(n <= 777)System.out.println(777);
		else if(n <= 888)System.out.println(888);
		else if(n <= 999)System.out.println(999);
										
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		for (int i = 1; i < 10; i++) {
			int ans = i*100 + i*10 + i;
			if (ans - N < 111 && ans - N >= 0) { 
				System.out.println(ans);
				return;
			}
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        int N = Integer.parseInt(s);

        for (int i = N; i < 1000; i++) {
            String str = String.valueOf(i);
            if (str.charAt(0) == str.charAt(1)
                && str.charAt(1) == str.charAt(2)) {
                System.out.println(i);
                break;
            }
        }
    }
}
//  [java]
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    private static final int ALL_DIGITS_SAME = 111;

    public static String process(TestCase testCase) {
        final int N = testCase.N;

        return String.valueOf(
                IntStream.range(1, 10)
                .map(i -> i * ALL_DIGITS_SAME)
                .filter(contestNum -> contestNum >= N)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("N is too large: " + N))
        );
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        return new TestCase(N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;

        public TestCase(int N) {
            this.N = N;
        }
    }
}
//  [java]
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(0);
        String a = "";
        String b = "";
        for (int i = 0; i<s.length(); i++){
            a += c;
        }
        for (int i = 0; i<s.length(); i++){
            b += Integer.parseInt(String.valueOf(c))+1;
        }
        if (Integer.parseInt(a) >= Integer.parseInt(s))
            System.out.println(a);
        else
            System.out.println(b);
    }
}
//  [cpp]
#include<stdio.h>
int main()
{
	int a,b,c[3];
	scanf("%d",&a);
	while(1){
		b=a;
		c[0]=b%10; b/=10;
		c[1]=b%10; b/=10;
		c[2]=b%10; b/=10;
		if(c[0]==c[1] && c[1]==c[2]) break;
		a++;
	}
	printf("%d%d%d\n",c[0],c[1],c[2]);
}
//  [cpp]
#include <cstdio>

int n;

int main(){
	scanf("%d",&n);
	for (int i = n ; i  ; i++){
		if (i % 111 == 0){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}
//  [cpp]
#include "bits/stdc++.h"

using namespace std;
int main()
{
	int n, i;
    cin >> n;
    int a, b, c;

    while (true)
    {
        i = n;
        a = i % 10;
        i /= 10;
        b = i % 10;
        i /= 10;
        c = i % 10;
        if (a == b && b == c && a == c)
        {
            cout << n << endl;
            break;
        }
        n++;
    }
	return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less{
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first < y.first;
    }
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};

int GCD(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}

ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}



int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int x; cin >> x;
    if(x<=111) cout << 111 << endl;
    else if(x<=222) cout << 222 << endl;
    else if(x<=333) cout << 333 << endl;
    else if(x<=444) cout << 444 << endl;
    else if(x<=555) cout << 555 << endl;
    else if(x<=666) cout << 666 << endl;
    else if(x<=777) cout << 777 << endl;
    else if(x<=888) cout << 888 << endl;
    else if(x<=999) cout << 999 << endl;
    cout << endl;
    
    
	return 0;
}
//  [cpp]
//#define LOCAL
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(ar) memset(ar,0,sizeof(ar))
#define go(i,a,b) for(int i=a;i<=b;++i)
#define f(i,n) for(int i=0;i<n;++i)


int main(){
#ifdef LOCAL
	freopen("data.in","r",stdin);
#endif
	int a[9] = {111,222,333,444,555,666,777,888,999};
	int n;
	scanf("%d",&n);
	for(int i=0;i<9;i++){
		if(a[i] >= n){
			printf("%d",a[i]);
			break;
		}
	}
	return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

int main(int argc, char *argv[]){

  int N;
  cin >> N;
  for(int i = 1; i <= 9; i++){
    if(111 * i >= N){
      cout << 111*i << endl;
      break;
    }
  }

  return 0;
}
//  [c]
#include <stdio.h>
int main(void){
    /* 変数宣言，ちゃんと初期化しよう */
    int A = 0;
    int ans = 0;
    /* 変数宣言終わり */
    
    /* 入力を受け付ける部分*/
    
    // %dはdecimalの略．つまり，入力を10進数として扱うよという意味．
    scanf("%d", &A);
    
    /* 入力を受け付ける部分終わり*/
    
    
    /* 何か処理*/
    if(A % 111 == 0){
    ans = A / 111 * 111; 
    }else{
    ans = A / 111 * 111 + 111;
    }
    
    if(1 == 0){
      /* 真の場合の処理 */
    }else{
      /* 偽の場合の処理 */
    }
    
    for(int i = 0; i < 10; i++){ 
      // i = 0,1,2,3,4,5,6,7,8,9のとき処理される
      
    }
    
    /* 何か処理終わり*/
    
    
    /* 出力する部分*/
    
    printf("%d", ans); // %dの部分にansの値が表示される
    
    /* 出力する部分*/
    
    
    
    return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int n,i,ans=0;
  scanf("%d",&n);
  for(i=1;i<10;i++){
    ans=i*111;
    if(n<=ans){
      break;
    }
  }
  printf("%d\n",ans);
  return 0;
}
//  [c]
//Atcoder-Begginer-Contest
//2018/10/1
//B

#include<stdio.h>

int main(void)
{
  int i,n;
  scanf("%d",&n);

  for(i=1;i<10;i++){
    if(n<=(111*i)&&n>=111*(i-1)){
      printf("%d\n",111*i);
      break;
    }
  }


  return 0;
}
//  [c]
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    if(n>=100 && n<=111){
        printf("%d\n",111);
    }
    else if(n<=222){
        printf("%d\n",222);
    }
    else if(n<=333){
        printf("%d\n",333);
    }
    else if(n<=444){
        printf("%d\n",444);
    }
    else if(n<=555){
        printf("%d\n",555);
    }
    else if(n<=666){
        printf("%d\n",666);
    }
    else if(n<=777){
        printf("%d\n",777);
    }
    else if(n<=888){
        printf("%d\n",888);
    }
    else if(n<=999){
        printf("%d\n",999);
    }
    return 0;
}
//  [c]
#include<stdio.h>
int main(){
  int n,ans=0;
  scanf("%d",&n);
  if(n%111==0){
   ans=n;
  }else{
   ans = ((n/111)+1)*111;
  }
  printf("%d",ans);
}
//  [c]
#include<stdio.h>

int main(void) {
   int N;
   scanf("%d", &N);

   int n = N / 100;
   int zzz = n * 111;

   if(zzz < N) {
      N = (n+1)*111;
   } else {
      N = zzz;
   }
   
   printf("%d\n", N);
   return 0;
   
}
//  [javascript]
(function(input) {
  'use strict';
  input.split("\n").some(function(line) {
    var number = parseInt(line, 10)
    while (number <= 999) {
      if (number % 111 == 0) {
        console.log(number)
        break
      } else {
        number += 1
      }
    }
  })
})(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
'use strict';
const main = input => {
  let n = parseInt(input[0]);
  while(Math.floor(n/100) != n%10 || Math.floor((n%100)/10) != n%10) n++;
  console.log(n);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));
//  [javascript]
function main(input) {
  var N = input[0]-0;
  var ans = 0;
  for(var i=111;i<=999;i+=111){
    if(N<=i){
      ans=i;
      break;
    }
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
//  [javascript]
function Main(input) {
  var current = parseInt(input)

  for (var i = current; i < 1000; i++) {
    var s = i.toString()
    if (s[0] === s[1] && s[1] === s[2]) {
      console.log(s);
      break;
    }
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  var ans="111";
  if(n<=111){
  }else if(n>=112&&n<=222){
    ans="222";
  }else if(n<=333){
    ans="333";
  }else if(n<=444){
    ans="444";
  }else if(n<=555){
    ans="555";
  }else if(n<=666){
    ans="666";
  }else if(n<=777){
    ans="777";
  }else if(n<=888){
    ans="888";
  }else{
    ans="999";
  }
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict';

function Main(input) {
  const inp = Number(input);
  const N = input.split("");
  const answerA = [N[0], N[0], N[0]].join("");
  const answerB = [Number(N[0])+1, Number(N[0])+1, Number(N[0])+1].join("");

  if(inp <= answerA) {
    console.log(answerA);
  } else {
    console.log(answerB);
  }

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	if n % 111 == 0 {
		fmt.Println(n)
	} else {
		d := (n / 111) + 1
		fmt.Println(100 * d + 10 * d + d)
	}
}
//  [go]
package main

import (
	"fmt"
)


func main() {
	var n int
	fmt.Scan(&n)

	for i := n; i<=999; i++ {
		if i%111 == 0 {
			fmt.Println(i)
			return
		}
	}

}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func zoro(n int) bool {
	return (n/100)%10 == (n/10)%10 && (n/10)%10 == n%10
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for ; !zoro(n); n++ {
	}
	fmt.Println(n)
}
//  [go]
package main

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

func main() {
	N := nextInt()

	for {
		strN := fmt.Sprint(N)
		diffRune := rune(strN[0])
		isSame := true
		for _, r := range strN {
			if diffRune != r {
				isSame = false
				break
			}
		}
		if isSame {
			break
		}

		N++
	}

	fmt.Println(N)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.
//  [go]
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n string
	fmt.Scan(&n)

	var ans []string
	for i := 0; i < len(n); i++ {
		ans = append(ans, string(n[0]))
	}
	origNum, _ := strconv.Atoi(n)
	ansNum, _ := strconv.Atoi(strings.Join(ans, ""))
	if ansNum < origNum {
		for i := 0; i < len(ans); i++ {
			num, _ := strconv.Atoi(ans[i])
			ans[i] = strconv.Itoa(num + 1)
		}
	}
	fmt.Println(strings.Join(ans, ""))
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var N float64
	fmt.Scan(&N)

	mod := math.Ceil(N / 111)

	fmt.Println(111 * mod)
}
//  [ruby]
n = gets.to_i
n += 1 while n.to_s.squeeze.size != 1
puts n
//  [ruby]
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
contest=[111,222,333,444,555,666,777,888,999]
ans=0
contest.each_with_index do|c,i|
  if N<=c
      ans=c
      break
  end
end
puts ans
//  [ruby]
n = gets.chomp.to_i


n.upto(999) do |i|
  s = i.to_s

  if s[0] == s[1] && s[1] == s[2] && s[2] == s[0]
    puts i
    exit
  end
end
//  [ruby]
n = gets.to_i
a = [111,222,333,444,555,666,777,888,999]
while n < 1000
  if a.include?(n)
    puts n
    break
  end
  n += 1
end
//  [ruby]
n = gets.to_i
[0,111,222,333,444,555,666,777,888,999].each_cons(2) do |a,b|
  puts b if (a+1..b).include? n
end
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

ans = nil
N.step(999) do |n|
  a, b, c = n.to_s.split('')
  if a == b && b == c
    ans = n
    break
  end
end

puts ans
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32
    }
    for i in n..1000 {
        let cs = i.to_string().chars().collect::<Vec<char>>();
        if cs.iter().all(|c| *c == cs[0]) {
            println!("{}", cs.into_iter().collect::<String>());
            return;
        }
    }
}
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<u32> = procon_read();
	let n = v[0];
	for i in 0.. {
		let d1 = (n+i)%10;
		let d2 = ((n+i)%100 - d1)/10;
		let d3 = ((n+i) - (n+i)%100)/100;
		if d1 == d2 && d2 == d3 {
			println!("{}", n+i);
			break;
		}
	}
}
//  [rust]
use std::io;


fn main() {
    let n = read_one::<usize>();
    let num = [111, 222, 333, 444, 555, 666, 777, 888, 999];
    for i in num.iter() {
        if n <= *i { println!("{}", i); break; }
    }
}


#[allow(unused)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize);

    println!(
        "{}",
        (1..10)
            .map(|x| x * 100 + x * 10 + x)
            .filter(|&x| x >= n)
            .min()
            .unwrap()
    );
}
//  [swift]
for i in Int(readLine()!)!...999{if i%111<1{print(i);break}}
//  [swift]
let N = Int(readLine()!)!
for i in N..<1000 {
    if i % 111 == 0 {
        print(i)
        break
    }
}
//  [swift]
let n = Int(readLine()!)!
if n > 888 {
  print(999)
} else if n > 777 {
  print(888)
} else if n > 666 {
  print(777)
} else if n > 555 {
  print(666)
} else if n > 444 {
  print(555)
} else if n > 333 {
  print(444)
} else if n > 222 {
  print(333)
} else if n > 111 {
  print(222)
} else {
  print(111)
}
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let s=ts()
  let a=Number(s[0])
  if(s[0]==s[1]&&s[1]==s[2])to(s)
  else{
    if(''+a+a+a<s){
      a++
      to(''+a+a+a)
    }
    else to(''+a+a+a)
  }
}
main()
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc111 {
    class ProgramA {
        /**
         * in
         *  112
         * out
         *  222
         */
        main(inp: string): void {
            const n: number = parseInt(inp, 10);
            for (let i: number = 0; i < 1000; i++) {
                if ((n + i) % 111 === 0) {
                    console.log(n + i);
                    break;
                }
            }
        }
    }

    const func = new ProgramA();
    func.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin)

let i = 1

const ans = _ => {
  while (1) {
    const res = 111 * i
    if (res >= n) {
      return res
    }
    i++
  }
}

console.log(ans())
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  for (let i = 1; i <= 9; i++) {
    const x = i * 100 + i * 10 + i;

    if (N <= x) {
      return x;
    }
  }

  return 0;
};

console.log(main(read()));
//  [typescript]
export default solve;

// =================================================
// ABC110B
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { nums } = parseLines(lines);

  const num = +nums.join('');
  let ans = 0;
  loop: for (let i = 9; i > 0; i--) {
    const v = +[i, i, i].join('');
    if (v >= num) {
      ans = v;
    } else {
      break loop;
    }
  }
  return ans.toString();
}

// helpers
function parseLines(lines: string[]) {
  const nums = lines[0].split('').map(s => +s);
  const obj = { nums };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume().setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}
//  [typescript]
const main = (): void => {
  const n = getParams();
  console.log(solve(n));
};

const getParams = (): number =>
  Number(getStdin());

const getStdin = (): string =>
  require('fs').readFileSync('/dev/stdin', 'utf8').trim();

const solve = (n: number): number =>
  Math.ceil(n / 111) * 111;

main();
//  [python]
n, k = (int(z) for z in input().split())
ans = 0
while n:
  n //= k
  ans += 1
print(ans)
//  [python]
def f(X, n):
    return f(int(X/n), n)+str(X%n) if (int(X/n)) else str(X%n)
n, k = map(int, input().split())
print(len(str(n)) if k == 10 else len(f(n, k)))
//  [python]
strings = input().split(' ')
N = int(strings[0])
K = int(strings[1])
 
ans = 1
max = K

while max <= N:
  max = max * K
  ans  =ans + 1
  
print(ans)
//  [python]
import sys
import heapq
import copy
import numpy as np
from collections import deque

n,k=list(map(int,input().split()))

print(int(np.floor(np.log(n)/np.log(k)))+1)
//  [python]
import numpy as np
import math

n,k = str(input()).split()
if int(n) == 0:
    print(1)
else:
    ans = np.log(int(n))/np.log(int(k))
    print(int(ans)+1)
//  [python]
import numpy as np
import math

n, k = map(int, input().split())

temp = np.log(n)/np.log(k)

if n==1:
    print(1)
else:
    print(math.ceil(temp))
//  [java]
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        System.out.println(getDigit(sc.nextInt(), sc.nextInt()));
    }

    static int getDigit(int n, int d) {
        return n / d != 0 ? 1 + getDigit(n / d, d) : 1;
    }

    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }


        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}
//  [java]

import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        final int k = scanner.nextInt();

        int count = 0;
        while (n > 0) {
            n /= k;
            count++;
        }
        System.out.println(count);
    }
}
//  [cpp]
#include <cstdio>
#define ll long long
int main(){
	ll n, k;
	scanf("%lld %lld", &n, &k);
	ll t = 1, c = 0;
	while (n >= t){
		t *= k;
		c++;
	}
	printf("%lld\n", c);
}
//  [cpp]
#include<cstdio>

int n, k;

int main() {
  scanf("%d %d", &n, &k);
  int ans = 0;
  long long m = 1;
  while (n >= m) {
    ++ans;
    m *= k;
  }
  printf("%d\n", ans);
}
//  [cpp]
#include<stdio.h>
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0;
	while(n!=0){
		n/=k;
		ans++;
	}
	if(ans==0) ans=1;
	printf("%d",ans);
	return 0;
}
//  [cpp]
#include<iostream>
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  int count=0;
  int num = 1;
  for(int i=0; i < n; i++){
    while (num < n+1){
      num = k*num;
      count = count+1;
      break;
    }
  }
  cout << count << endl;
}