#include <iostream>
#include <utility>
#include <vector>
#include <map>
#include <algorithm>
#include <iterator>
#include <fstream>
#include <cstdio>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <queue>
#include <stack>
using namespace std;


#define FILEIO 0


typedef long long ll;
typedef pair<int, int> pll;
typedef vector<int> vi;
typedef map<int,int> mii;
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 4e5 + 5;


namespace io {
    class Reader {
        int bytesRead = 0;
        int curChar = 0;
        static const int bufSize = 8192;
        char buf[bufSize];
        int descriptor;
    public:
        Reader(int d = -1): descriptor(d) {};
        void setFileDescriptor(int d) {
            this->descriptor = d;
        }
        bool isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\0' || c == EOF;
        }
        // Read the value and move pointer to the right.
        int nextChar() {
            if (descriptor == -1) {
                try {
                    throw "You must first call [setFileDescriptor(int descriptor)]";
                } catch (const char* msg) {
                    cout << msg << endl;
                }
            }
            if (bytesRead < 0) {
                try {
                    throw "Error reading bytes from fileDescriptor = " + to_string(descriptor);
                } catch (const char* msg) {
                    cout << msg << endl;
                }
            }
            if (curChar >= bytesRead) {
                curChar = 0;
                bytesRead = read(descriptor, buf, bufSize - 1);
                if (bytesRead <= 0) {
                    return EOF;
                }
                buf[bytesRead] = '\0';
            }
            return buf[curChar++];
        }
        int nextInt() {
            if (descriptor == -1) {
                try {
                    throw "You must first call [setFileDescriptor(int descriptor)]";
                } catch (const char* msg) {
                    cout << msg << endl;
                }
            }
            int c = 0;
            while (isSpaceChar(c) && c != EOF) {
                c = nextChar();
            }
            if (c == EOF) {
                try {
                    throw "Input mismatch exception";
                } catch (const char* msg) {
                    cout << msg << endl;
                    return EOF;
                }
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = nextChar();
            }
            int res = 0;
            while (!isSpaceChar(c)) {
                if (c < '0' || c > '9') {
                    try {
                        throw "Input mismatch exception";
                    } catch (const char* msg) {
                        cerr << msg << endl;
                    }
                }
                res *= 10;
                res += c - '0';
                c = nextChar();
            }
            return res * sgn;
        }
        string nextString() {
            if (descriptor == -1) {
                try {
                    throw "You must first call [setFileDescriptor(int descriptor)]";
                } catch (const char* msg) {
                    cout << msg << endl;
                }
            }
            int c = nextChar();
            while (isSpaceChar(c) && c != EOF) {
                c = nextChar();
            }
            string res;
            while (!isSpaceChar(c)) {
                res += (char)(c);
                c = nextChar();
            }
            return res;
        }
    };
    //
    class Writer {
        ofstream* redirectFile = nullptr;
        streambuf* coutBuffer = nullptr;
    public:
        Writer() {}
        Writer(const string& filename) {
            redirectFile = new ofstream(filename);
            coutBuffer = cout.rdbuf();
            cout.rdbuf(redirectFile->rdbuf());
        }
        ~Writer() {
            if (redirectFile != nullptr) {
                delete redirectFile;
            }
            if (coutBuffer != nullptr) {
                cout.rdbuf(coutBuffer);
            }
        }


        template< typename T > void print(T arg) {
            cout << arg;
        }
        template< typename T >
        void println(T arg) {
            cout << arg << endl;
        }

    };
};

namespace graph {
    const static int WHITE = 0;
    const static int GRAY = 1;
    const static int BLACK = 2;

    class Graph {
    public:
        Graph(int v): v(v) {
            adj.resize(v + 1, vector< int >(0));
            color.resize(v + 1, WHITE);
        }
    private:
        void restore() {
            color.resize(0);
            color.resize(v + 1, WHITE);
        }
        int v;
        vector< vector< int > > adj;
        vector< int > color;

    };
};


namespace utils {
    int higher(vector<int> &a, int lo, int hi, int key) {
        while (lo <= hi) {
            int m = (lo + hi) >> 1;
            if (a[m] > key) {
                hi = m - 1;
            } else {
                lo = m + 1;
            }
        }
        return lo;
    }

    int lower(vector<int> &a, int lo, int hi, int key) {
        while (lo <= hi) {
            int m = (lo + hi) >> 1;
            if (a[m] < key) {
                lo = m + 1;
            } else {
                hi = m - 1;
            }
        }
        return hi;
    }
}

void solve(io::Reader& in, io::Writer& out) {
    int n = in.nextInt();
    int ans = -1;
    while (n <= 999) {
        int d2 = n % 10;
        int d1 = (n / 10) % 10;
        int d0 = n / 100;
        if (d0 == d1 && d1 == d2 && ans == -1) {
            ans = n;
        }
        ++n;
    }
    out.println(ans);
}



int main() {
    io::Reader* in = nullptr;
    io::Writer* out = nullptr;
    if (FILEIO) {
        int fd_in = open("input.txt", O_RDWR);
        in = new io::Reader(fd_in);
        out = new io::Writer("output.txt");
    } else {
        int fd_in = STDIN_FILENO;
        in = new io::Reader(fd_in);
        out = new io::Writer();
    }
    solve(*in, *out);
    if (in != nullptr) {
        delete in;
    }
    if (out != nullptr) {
        delete out;
    }
    return 0;
}

Measured memory_bytes: 256