// Задача "Дана строка"
// 9-ая Интернет-олимпиада сезона 2007-2008, базовый уровень
// Автор задачи: Федор Царев, tsarev@rain.ifmo.ru
// Автор решения: Федор Царев, tsarev@rain.ifmo.ru

import java.io.*;
import java.util.*;

public class string_ft implements Runnable {

	public final static int MAX_N = (int) 2e5;

	private Scanner in;
	private PrintWriter out;
	String fname = "string";

	private void myAssert(boolean e, String message) {
		if (!e) {
			throw new Error("Assertion failure!!! " + message);
		}
	}

	public void solve() {
		String s = in.next();
		int n = s.length();
		char[] c = s.toCharArray();
		myAssert(1 <= n && n <= 2e5, "");
		for (int i = 0; i < n; i++) {
			myAssert('a' <= c[i] && c[i] <= 'z', "");
		}
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, c[i]);
			min = Math.min(min, c[i]);
		}
		int lastMin = -1;
		int lastMax = -1;
		int ansLen = Integer.MAX_VALUE;
		int ansPos = -1;
		for (int i = 0; i < n; i++) {
			if (c[i] == max) {
				if (lastMin != -1) {
					int cl = i - lastMin + 1;
					if (cl < ansLen) {
						ansPos = lastMin;
						ansLen = cl;
					}
				}
				lastMax = i;
			}
			if (c[i] == min) {
				if (lastMax != -1) {
					int cl = i - lastMax + 1;
					if (cl < ansLen) {
						ansPos = lastMax;
						ansLen = cl;
					}
				}
				lastMin = i;
			}			
		}
		out.println(s.substring(ansPos, ansPos + ansLen));
	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}		
	}

	public string_ft() {
		try {
			in = new Scanner(new File(fname + ".in"));
			out = new PrintWriter(new File(fname + ".out"));
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}


	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new string_ft()).start();
	}

}                       