Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        For i As Integer = N To Integer.MaxValue
            If Judge(i) Then
                WriteLine(i)
                Exit For
            End If
        Next
    End Sub

    Function Judge(n As Integer) As Boolean
        Dim i, j As Integer
        Do While n <> 0
            If i = 0 Then
                j = n Mod 10
            Else
                If n Mod 10 <> j Then Return False
            End If
            n \= 10
            i += 1
        Loop
        Return True
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
