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

public class Main {
	public static void main(String[] args) /*throws FileNotFoundException*/ {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA{
     static boolean twofind(String s, String t){
    	 int index = s.indexOf(t);
    	 int index2 = s.indexOf(t, index + 1);
    	 if(index2 != -1)return true;
    	 return false;
     }
	public void solve(int testNumber, FastScanner scan, FastPrinter out) /*throws FileNotFoundException*/ {
		//Scanner sscan = new Scanner(new File("input.txt"));
		//PrintStream oout = new PrintStream(new File("output.txt"));
	     String s = scan.next();
	     String ans = "";
	     boolean ok = false;
	     for(int i = s.length(); i >= 0; i--){
	        for(int j = 0; j <= s.length() - 1; j++){
	        	try{
	        		if(twofind(s, s.substring(j, j + i))){
	        			ans = s.substring(j, j + i); break;
	        		}
	        	}catch(Exception e){
	        		break;
	        	}
	        }
	        if(!ans.equals(""))break;
	     }

	     out.println(ans.length());
		//sscan.close();
		//oout.close();
	}
}

class FastScanner extends BufferedReader {
	public FastScanner(InputStream is) {
		super(new InputStreamReader(is));
	}

	public int read() {
		try{
			int ret = super.read();
			return ret;
		}catch(Exception e){
			throw new InputMismatchException();
		}
	}

	public String next() {
        StringBuilder sb = new StringBuilder();
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        if (c < 0) {
            return null;
        }
        while (c >= 0 && !isWhiteSpace(c)) {
            sb.appendCodePoint(c);
            c = read();
        }
        return sb.toString();
    }

	static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

	public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (c >= 0 && !isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

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

	public BigInteger nextBigInteger() {
		return new BigInteger(next());
	}

	public BigDecimal nextBigDecimal(){
		return new BigDecimal(next());
	}

	public String readLine(){
		try{
			return super.readLine();
		}catch(IOException e){
			return null;
		}
	}
}

class FastPrinter extends PrintWriter {

	public FastPrinter(OutputStream out) {
		super(out);
	}
	public FastPrinter(Writer out) {
		super(out);
	}
}


import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        sc.close();

        int maxm=0;
        int ind1,ind2;

        for(int i=0;i<str.length();i++){
            for(int j=i+1;j<str.length();j++){
                int len=0;
                ind1=i;ind2=j;
                while(ind2<str.length() && str.charAt(ind1)==str.charAt(ind2)){
                    ind1++;
                    ind2++;
                    len++;
                }
                maxm=Math.max(maxm,len);
            }
        }
        System.out.println(maxm);
    }
}


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

public class StringRepeat
{
	static Scanner in = new Scanner( new BufferedReader( new InputStreamReader( System.in ) ) );

	public static void main( String[] args )
	{
		String s = in.next();
		int n = s.length(), ans = 0;
		for( int i = 0; i < n; i++ ) for( int j = i+1; j < n; j++ )
		{
			int l = 0;
			while( j+l<n && s.charAt(i+l)==s.charAt(j+l) ) l++;
			ans = Math.max( ans, l );
		}
		System.out.println( ans );
	}
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class BetaRound23_A implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok = new StringTokenizer("");

	void init() throws IOException {
		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	@Override
	public void run() {
		try {
			long t1 = System.currentTimeMillis();
			init();
			solve();
			out.close();
			long t2 = System.currentTimeMillis();
			System.err.println("Time = " + (t2 - t1));
		} catch (Exception e) {
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	public static void main(String[] args) {
		new Thread(new BetaRound23_A()).start();
	}

	void solve() throws IOException {
		char[] s = in.readLine().toCharArray();
		int n = s.length;
		for (int ans = n - 1; ans >= 1; ans--) {
			for (int i = 0; i < n - ans + 1; i++) {
				for (int j = i + 1; j < n - ans + 1; j++) {
					int count = 0;
					for (int k = 0; k < ans; k++) {
						if (s[i + k] == s[j + k]) count++;
						else break;
					}
					if (count == ans) {
						out.print(ans);
						return;
					}
				}
			}
		}
		out.print(0);
	}

}


import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class P19 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Map<Integer, Integer> mapa = new HashMap<Integer, Integer>();
        String str = in.next();
        int len = str.length();
        int maxCurrent = 0;
        for (int i = 0; i < len; ++i) {
            for (int j = 1; j <= len; ++j) {
                if (i + j > len) continue;
                //System.out.format("Adding from %d to %d -> %s\n",i, i+j,str.substring(i, i + j));
                int hashCode = str.substring(i, i + j).hashCode();
                Integer current = mapa.get(hashCode);
                if (current == null)
                    current = 0;
                current++;
                mapa.put(hashCode, current);
                if (current > 1)
                    maxCurrent = Math.max(maxCurrent, j);
            }
        }

        out.println(maxCurrent);

        out.flush();
        out.close();
    }
}


import java.io.*;
public class j
{
public static void main(String a[])throws IOException
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
int n=0,i=0,k=2;
String s="\0",r="\0";
s=b.readLine();
n=s.length()-1;
while(k<=s.length())
{
for(i=0;i<k;i++)
{
r=s.substring(i,i+n);
if(s.indexOf(r)!=s.lastIndexOf(r))
{
System.out.print(n);
System.exit(0);
}
}
k++;
n--;
}
System.out.print("0");
}
}


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

public class Main {
	static Scanner in;
	static PrintWriter out;
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}

	public static void main(String[] args) throws Exception {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
//		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

		String s = in.next();
		int n = s.length();

		int max = 0;
		for (int i = 1; i < n; i++) {
			String[] subs = new String[n - i + 1];
			for (int j = 0; j + i <= n; j++) subs[j] = s.substring(j, j + i);
			Arrays.sort(subs);
			boolean flag = false;
			for (int j = 0; j < n - i; j++)
				if (subs[j].equals(subs[j + 1])) flag = true;
			if (flag) max = Math.max(max, i);
		}

		out.println(max);

		out.close();
	}
}


import java.util.*;
public class A23 {
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		ArrayList<String>Q = new ArrayList<String>();
		for (int i = 0; i < W.length(); i++){
			String O = "";
			for (int k = i; k < W.length(); k++){
				O = O + W.charAt(k);
				Q.add(O);
			}
		}
		Collections.sort(Q);
		String tmp = Q.get(0);
		int y = 0;
		for (int i = 1; i < Q.size(); i++){
			if (Q.get(i).equals(tmp)){
				if (Q.get(i).length() > y){
					y = Q.get(i).length();
				}
			}
			else {
				tmp = Q.get(i);
			}
		}
		System.out.println(y);
	}
}


import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
import java.math.*;

public class Main {

    void run() throws IOException {
        String s = token();
        HashSet <String> h;
        int n = s.length();
        int r = 0;
        loop: for (int i = 1; i <= n; i++) {
            h = new HashSet();
            for (int j = 0; j < n - i + 1; j++) {
                String t = s.substring(j, j + i);
                if (h.contains(t)) {
                    r = i;
                    continue loop;
                } else {
                    h.add(t);
                }
            }
        }
        System.out.println(r);
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        //final String FILENAME = "dvd";
        //in = new BufferedReader(new FileReader(new File(FILENAME + ".in")));
        //out = new PrintWriter(new File(FILENAME + ".out"));
        in = new BufferedReader(new InputStreamReader(System.in));
        //in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        st = new StringTokenizer(" ");
        new Main().run();
        out.close();
    }

    static BufferedReader in;
    //static Scanner in;
    static PrintWriter out;
    static StringTokenizer st;

    String token() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    int nint() throws IOException {
        return Integer.parseInt(token());
    }

    long nlong() throws IOException {
        return Long.parseLong(token());
    }

    double ndouble() throws IOException {
        return Double.parseDouble(token());
    }
}


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

public class Solution {

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	void solve() throws IOException {
		String s = next();
		HashSet<String> set = new HashSet<String>();
		int ans = 0;
		for (int i = 0; i < s.length(); ++i) {
			for (int j = i + 1; j <= s.length(); ++j) {
				String t = s.substring(i, j);
				if (set.contains(t)) {
					ans = Math.max(ans, t.length());
				}
				set.add(t);
			}
		}
		out.println(ans);
	}

	Solution() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		eat("");

		solve();

		in.close();
		out.close();
	}

	private void eat(String str) {
		st = new StringTokenizer(str);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

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

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

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

	public static void main(String[] args) throws IOException {
		new Solution();
	}
}


import java.util.Scanner;

public class GivenString {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        String s = input.nextLine();

        int max = 0;

        for(int i = 0; i < s.length(); i++) {
            for(int j = i + 1; j <= s.length(); j++) {
                String tmp = s.substring(i, j);
                int match = 0;
                for(int k = 0; k + tmp.length() <= s.length(); k++) {
                    if(tmp.equals(s.substring(k, k + tmp.length()))) {
                        match++;
                    }
                }
                if(match >= 2) {
                    max = Math.max(max, tmp.length());
                }
            }
        }
        System.out.println(max);
        System.exit(0);
    }
}


import java.io.*;
public class Main
{
     public static void main(String []args)throws Exception
    {
        String inp="";
        String res="";
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        inp=br.readLine();
        for(int i=0;i<inp.length();i++)//counts the length
        {
            for(int j=0;j<(inp.length()-i);j++)//start index of string
            {
                for(int k=j+1;k<=inp.length()-i;k++)
                {
                    if(inp.substring(j,j+i).equals(inp.substring(k,k+i)))
                       res =inp.substring(j,j+i);
                }
            }
        }
        System.out.println(res.length());

     }
}


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

public class A23 {

    static int solve(String s) {
        for(int i = s.length(); i > 0; --i) {
            for(int start = 0; start < s.length() - i; ++start) {
                String str = s.substring(start, start + i);
                int firstIndex = s.indexOf(str);
                int lastIndex = s.lastIndexOf(str);
                if(firstIndex != lastIndex)
                    return i;
            }
        }
        return 0;
    }

    public static String[] EX = new String[] { "abcd", "ababa", "zzz", "qwertyuiopasdfghjklzxcvbnmqwepriuwpoep"};
    public static int[] EX_A = new int[] { 0, 3, 2, 3};

    public static void main(String[] args) throws IOException {
        if(true) {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String s = br.readLine();
            System.out.println(solve(s));
        }
        else {
            for(int i = 0; i < EX.length; ++i) {
                int result = solve(EX[i]);
                System.out.println(i + ": " + result + " " + (result == EX_A[i]? "ja" : "NEJ"));
            }
        }
    }

}


import java.util.*;
import java.io.*;
public class Longest {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		int max=0;
		for(int i=0;i<str.length();i++)
		{
			for(int x=0;x+i<=str.length();x++)
			{
				if(contains(str,str.substring(x,x+i),x))
				{
					//System.out.println(str.substring(x,x+i));
					max=Math.max(max, i);
				}
			}
		}
		System.out.println(max);
	}
	public static boolean contains(String whole,String part,int start)
	{

		if(whole.indexOf(part, start+1)>=0)return true;
		return false;
	}
}


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

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        for (int i = s.length() - 1; i > 0; i--)
            for (int j = 0; j <= s.length() - i; j++)
                if (s.substring(0, j + i - 1).contains(s.substring(j, j + i))
                        || s.substring(j + 1).contains(s.substring(j, j + i))) {
                    System.out.println(i);
                    return;
                }
        System.out.println(0);
    }
}


import java.util.*;
public class C23A {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        String str=sc.next();

        for(int k=str.length()-1;k>=1;k--){
            for(int i=0;i<=str.length()-k;i++){
                for(int j=i+1;j<=str.length()-k;j++){
                    if(str.substring(i,i+k).equals(str.substring(j,j+k))){
                            System.out.println(k);
                            return;
                    }
                }
            }
        }
        System.out.println(0);

    }
}


import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder text = new StringBuilder(in.nextLine()); String substr; String max="";
        for(int i=2; i<=text.length(); i++){
            for(int j=0; j<i; j++){
                substr = text.substring(j, i);
                if(text.lastIndexOf(substr) != text.indexOf(substr)){
                    if(substr.length() > max.length()){  max = substr;}
                }
            }
        }
        System.out.println(max.length());
    }
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.Entry;

public class StringsProb {
    private void solve() throws IOException {
        String s = nextToken();
        int res = 0;
        Map<String , Integer> m = new HashMap<String, Integer>();
        for (int i = 0; i < s.length(); i++)
            for (int j = 0; j <= s.length(); j++) {
                if (i > j) continue;
                String a = s.substring(i , j);
                if (a.equals("")) continue;
                if (m.containsKey(a)) {
                    m.put(a, m.get(a) + 1);
                }
                else
                    m.put(a, 1);
            }
        for (Entry<String , Integer> e : m.entrySet()) {
            if (e.getValue() >= 2)
                res = Math.max(res, e.getKey().length());
        }
        System.out.println(res);
    }

    public static void main(String[] args) {
        new StringsProb().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = nextLong();
        }
        return res;
    }

    double[] readDoubleArray(int size) throws IOException {
        double[] res = new double[size];
        for (int i = 0; i < size; i++) {
            res[i] = nextDouble();
        }
        return res;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


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

public class substring {
	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;
	public static void main(String[] args) throws IOException {
		InputStream input = System.in;
		//InputStream input = new FileInputStream("fileIn.in");
		OutputStream output = System.out;
		//OutputStream output = new FileOutputStream("fileOut.out");
		br = new BufferedReader(new InputStreamReader(input));
		out = new PrintWriter(output);
		String in = br.readLine();
      int len = in.length();
      int doub = len;
      boolean found = false;
      while (!found)
         {
         int count = 0;
         String[] parts = new String[len - doub + 1];
         for (int i = 0; i < len - doub + 1; i++)
            parts[i] = in.substring(i,i+doub);
         for (int i = 1; i < len - doub + 1; i++)
            for (int j = 0; j < i; j++)
               if (parts[i].equals(parts[j]))
                  count++;
         if (count >= 1)
            found = true;
         doub--;
         }
      out.println(doub+1);
		out.close();
	}
}


import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		String str;
		int i,j,k;
		int cnt = 0;
		char [] strArray;

		str = cin.next();
		strArray = str.toCharArray();

		for(i = 0; i < strArray.length; i ++)
			for(j = i + 1; j < strArray.length; j ++)
			{
				for(k = 0; (((i + k) < strArray.length && (j + k) < strArray.length) && (strArray[i + k] == strArray[j + k])); k ++)
					if(k + 1> cnt) cnt = k + 1;
			}

		System.out.println(cnt);
	}
}


import java.util.*;

public class A23 {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	char[] input = sc.nextLine().toCharArray();
	int[][] dyn = new int[input.length][input.length];
	int max = 0;
	for(int a = 0; a < input.length; a++) {
	    for(int b = a + 1; b < input.length; b++) {
		if(input[a] == input[b]) {
		    int prev = (a == 0) ? 0 : dyn[a-1][b-1];
		    dyn[a][b] = prev + 1;
		    max = (dyn[a][b] > max) ? dyn[a][b] : max;
		}
	    }
	}
	System.out.println(max);
    }
}


import java.io.*;
import java.util.Scanner;
import java.lang.String;
public class A23 {
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String s = in.nextLine();
    int i=0,j=0,n=0,t=0,count=0;
    n=s.length();
    String s1="y",s2="yu6j";
    for(t=1;t<n;t++)
        {
        for(i=0;i<t;i++)
            {
            s1=s.substring(i,i+n-t);
            for(j=i+1;j<=t;j++)
                {
                s2=s.substring(j,j+n-t);
                if(s1.equalsIgnoreCase(s2))
                    {
                    count++;break;
                    }
                if(count==1) break;
                }
            if(count==1) break;
            }
        if(count==1) break;
        }
	if(n==0)
		{
	  System.out.println("0");
		}
	else
	{
    if(count==1)
    {
    System.out.println(s1.length());
    }
    else  System.out.println("0");
    }
	}
}


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

public class A {
	String line;

	void run()throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		line = bf.readLine();
		int i, j, len = line.length(), max=0;
		for(i=0; i<len; i++){
			for(j=i; j<len; j++){
				if(line.indexOf(line.substring(i,j+1), i+1)>0){
					if(j-i+1>max) max = j-i+1;
				}
			}
		}
		System.out.println(max);
	}

	public static void main(String[] args)throws IOException {
		new A().run();
	}
}


import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class CF23A implements Runnable{

    public static void main(String args[]){
       new CF23A().run();
    }

    @Override
    public void run(){
        try{
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            tok = null;
            solve();
            in.close();
            out.close();

        }
        catch(IOException e){
            e.printStackTrace();
            System.exit(0);
        }
    }

    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }

    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException{
        return Long.parseLong(nextToken());
    }

    String nextToken()throws IOException{
        while(tok == null || !tok.hasMoreTokens()){
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;
    //////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////
    private void solve()throws IOException{
        String s = nextToken();
        int l = s.length();
        int ans = 0;
        for(int i = 0; i < l - 1; i++){
            for(int j = i + 1; j < l; j++){
                String now = s.substring(i, j);
                if(s.substring(i + 1).indexOf(now) >= 0){
                ans = Math.max(ans, j - i);

            }
            }
        }

        out.println(ans);
    }
}


import java.util.*;

public class Solution
{
    public static void main(String[] args)
    {
        new Solution().calc();
    }

    void calc()
    {
        Scanner cin = new Scanner(System.in);
        String s = cin.next();
        int ret = 0;
        for (int i = 0; i < s.length(); i++)
        {
            for (int j = i + 1; j < s.length(); j++)
            {
                for (int k = 0; j + k < s.length(); k++)
                {
                    if (s.charAt(i + k) != s.charAt(j + k)) break;
                    ret = Math.max(k + 1, ret);
                }
            }
        }
        System.out.println(ret);
    }
}


import java.util.Scanner;

public class A023 {
	public static void main(String[] args) {
		System.out.println(f());
	}

	static int f() {
		Scanner in = new Scanner(System.in);
		String line = in.next();
		for (int length = line.length(); length > 0; length--) {
			for (int start = 0; start + length <= line.length(); start++) {
				if(line.indexOf(line.substring(start,start+length),start+1)>=0) {
					return length;
				}
			}
		}
		return 0;
	}
}


import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.lang.Character.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class A {
    public void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        String[] ss = new String[n];
        for (int i = 0; i < n; i++)
            ss[i] = s.substring(i);
        sort(ss);
        int res = 0;
        for (int i = 1; i < n; i++)
            res = max(res, count(ss[i - 1], ss[i]));
        System.out.println(res);
    }

    int count(String s, String t) {
        int ret = 0;
        for (int i = 0; i < min(s.length(), t.length()); i++)
            if (s.charAt(i) != t.charAt(i))
                return ret;
            else
                ret++;
        return ret;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String... args) {
        new A().run();
    }
}


import java.util.Scanner;

public class A_YoureGivenAString {

    //1:11

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.nextLine();

        for (int l = str.length()-1; l >= 1; l--) {
            for (int i = 0; i < str.length()-l+1; i++) {
                String subs = str.substring(i, i+l);
                if(str.lastIndexOf(subs) != i){
                    System.out.println(l);
                    return;
                }
            }
        }
        System.out.println(0);
    }

}


import java.io.PrintWriter;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = in.nextLine();

        int ans = 0;

        outer: for (int i = s.length() - 1; i >= 1; i--)
            for (int j = 0; j < s.length() - i; j++) {
                String sub = s.substring(j, j + i);
                String str = s.substring(j + 1);

                if (str.contains(sub)) {
                    ans = i;
                    break outer;
                }
            }

        out.print(ans);
        out.close();
    }
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        int n = line.length();
        int maxlenght = 0;
        for (int i = 0; i < n; i++) {
            int j = line.indexOf(line.charAt(i), i + 1);
            while (j != -1) {
                int k = i;
                int l = j;
                while (k < n && l < n && line.charAt(k) == line.charAt(l)) {
                    k++;
                    l++;
                }
                if (k - i > maxlenght) {
                    maxlenght = k - i;
                }
                j = line.indexOf(line.charAt(i), j + 1);
            }
        }
        System.out.println(maxlenght);
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;

/**
 * @author Egor Kulikov (egor@egork.net)
 *         Created on 14.03.2010
 */
public class TaskA implements Runnable {
	private InputReader in;
	private PrintWriter out;

	public static void main(String[] args) {
		new Thread(new TaskA()).start();
//		new Template().run();
	}

	public TaskA() {
//		String id = getClass().getName().toLowerCase();
//		try {
//			System.setIn(new FileInputStream(id + ".in"));
//			System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//			System.setIn(new FileInputStream("input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream("output.txt")));
//		} catch (FileNotFoundException e) {
//			throw new RuntimeException();
//		}
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}

	public void run() {
//        int numTests = in.readInt();
//        for (int testNumber = 0; testNumber < numTests; testNumber++) {
//			out.print("Case " + (testNumber + 1) + ": ");
//        }
		String s = in.readString();
		Set<String> m = new HashSet<String>();
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			for (int j = i + 1; j <= s.length(); j++) {
				if (m.contains(s.substring(i, j)))
					ans = Math.max(ans, j - i);
				else
					m.add(s.substring(i, j));
			}
		}
		out.print(ans);
		out.close();
	}

	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1000];
		private int curChar, numChars;

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

		private 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 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 String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuffer res = new StringBuffer();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private String readLine0() {
			StringBuffer buf = new StringBuffer();
			int c = read();
			while (c != '\n' && c != -1) {
				buf.appendCodePoint(c);
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0)
				s = readLine0();
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines)
				return readLine();
			else
				return readLine0();
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(readString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char readCharacter() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			return (char) c;
		}

		public double readDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
	}
}


import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		new A().run();
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int res = 0;
		for (int i = 0; i < s.length(); i++)
			for (int j = i + 1; j <= s.length(); j++) {
				String sub = s.substring(i, j);
				int c = count(s, sub);
				if (c >= 2)
					res = Math.max(res, sub.length());
			}
		System.out.println(res);
	}

	private int count(String s, String sub) {
		int res = 0;
		while (s.length() > 0) {
			if (s.startsWith(sub))
				res++;
			s = s.substring(1);
		}
		return res;
	}

}


import java.io.*;
import java.math.BigInteger;

public class Main {
	BufferedReader in;
	PrintWriter out;

	public static void main(String[] args) throws IOException
	{
		new Main().run();
	}
	public void run() throws IOException
	{
		//in=new BufferedReader(new FileReader("input.txt"));
		//out=new PrintWriter(new FileWriter("output.txt"));
		in=new BufferedReader(new InputStreamReader(System.in));
		out=new PrintWriter(new OutputStreamWriter(System.out));
		solve();

		out.flush();
	}

	public void solve() throws IOException
	{
		String now=in.readLine();
		int l=now.length();
		int answ=0;
		for(int i=0;i!=l;i++)
			for(int j=i+1;j<l;j++)
			{
				String a=now.substring(i, j);
				for(int k=i+1;k<l-j+i+1;k++)
					if(a.compareTo(now.substring(k, k+j-i))==0)
						answ=Math.max(answ, a.length());
			}
		out.print(answ);

	}
}


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

public class Main {

    public static void main(String[] args)throws java.lang.Exception {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     String s = br.readLine();
     int max = 0;
        for (int i = 0; i < s.length(); i++) {
            for (int j = i+1; j < s.length(); j++) {
                if(s.substring(i+1).contains(s.substring(i,j)))
                    max = Math.max(max, j-i);

            }}
            System.out.println(max);

    }

}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class A {
	public static void main(String[] args) throws Exception{
		String str = new Scanner(System.in).next();
		Set<String> set = new HashSet<String>();
		String max = "";
		for(int l = 1; l < str.length(); ++l){
			for(int i = 0; i < str.length()-l; ++i){
				String substr = str.substring(i, i+l);
				if(!set.contains(substr) && str.indexOf(substr) != str.lastIndexOf(substr)){
					set.add(substr);
					if(substr.length() > max.length()){
						max = substr;
					}
				}
			}
		}
		System.out.println(max.length());
	}

}


import java.util.*;

public class A
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);

        String str = scan.next();

        for(int i=str.length();i >= 1;i--)
        {
            for(int j=0;j + i <= str.length();j++)
            {
                String sub = str.substring(j, j+i);

                int index = str.indexOf(sub, j+1);

                if(index > -1)
                {
                    System.out.println(i);
                    return;
                }

            }
        }

        System.out.println(0);
    }
}


import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.util.*;

public class Main {
    static boolean LOCAL = false;//System.getSecurityManager() == null;
    Scanner sc = new Scanner(System.in);

    void run() {
        char[] cs = sc.nextLine().toCharArray();
        int res = 0;
        for (int s1 = 0; s1 < cs.length; s1++) {
            for (int s2 = s1 + 1; s2 < cs.length; s2++) {
                int len = 0;
                while (s2 + len < cs.length && cs[s1 + len] == cs[s2 + len]) {
                    len++;
                }
                res = max(res, len);
            }
        }
        System.out.println(res);
    }

    class Scanner {
        BufferedReader br;
        StringTokenizer st;
        Scanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            eat("");
        }
        void eat(String s) {
            st = new StringTokenizer(s);
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        boolean hasNext() {
            while (!st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null) return false;
                eat(s);
            }
            return true;
        }
        String next() {
            hasNext();
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    void debug(Object...os) {
        System.err.println(deepToString(os));
    }

    public static void main(String[] args) {
        if (LOCAL) {
            try {
                System.setIn(new FileInputStream("in.txt"));
            } catch (Throwable e) {
                LOCAL = false;
            }
        }
        if (!LOCAL) {
            try {
                Locale.setDefault(Locale.US);
                System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
            } catch (Throwable e) {
            }
        }
        new Main().run();
        System.out.flush();
    }
}


import java.io.*;
import java.util.*;
public class a23
{
    public static void main(String args[])throws IOException
    {
        InputStreamReader read=new InputStreamReader(System.in);
        BufferedReader in=new BufferedReader(read);
        String s,subs;
       // System.out.println("Enter");
        s=in.readLine();
        int i,j,k,l=0,a=1,sl=0;
        for(i=0;i<s.length();i++)
        {
            a=1;
            for(j=i;j<s.length();j++)
            {
                subs=s.substring(i,i+a);
                for(k=i;k<(s.length()-a+1);k++)
                {
                    if(subs.compareTo(s.substring(k,k+a))==0)
                    l++;
                    if(l==2)
                    {
                        if(a>sl)
                        sl=a;
                        l=0;
                        break;
                    }
                }
                l=0;
                a++;
            }
        }
        System.out.println(sl);
    }
}


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

public class A {

    public static void main(String[] args) throws IOException {
        new A().solve();
    }

    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    private void solve() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        String s = nextToken();
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            for (int j = i + 1; j < s.length(); j++) {
                int k = 0;
                while (k < s.length() - j && s.charAt(i + k) == s.charAt(j + k)) {
                    k++;
                }
                res = Math.max(res, k);
            }
        }
        PrintWriter pw = new PrintWriter(System.out);
        pw.println(res);
        pw.close();
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

}


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

public class Main {
    public static Scanner scan = new Scanner(System.in);
    public static boolean bg = true;

    public static void main(String[] args) throws Exception {
        String k1 = scan.next();
        HashSet<String> met = new HashSet();
        String ans = "";
        for (int i=1;i<=k1.length()-1;i++){
            for (int j=0;j+i<=k1.length();j++){
                String cur = k1.substring(j, j+i);
                if (!met.contains(cur)){
                    met.add(cur);
                }
                else {
                    if (cur.length()>ans.length())ans=cur;
                }
            }
        }
        System.out.println(ans.length());

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class A23 {

	static StreamTokenizer in;
	static PrintWriter out;

	static int nextInt() throws IOException {
		in.nextToken();
		return (int)in.nval;
	}

	static String nextString() throws IOException {
		in.nextToken();
		return in.sval;
	}

	public static void main(String[] args) throws IOException {
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		out = new PrintWriter(System.out);

		String s = nextString();

		for (int i = s.length(); i > 0; i--) {
			for (int j = 0; j+i-1 < s.length(); j++)
				for (int k = j+1; k+i-1 < s.length(); k++)
					if (s.substring(j, j+i).equals(s.substring(k, k+i))) {
						out.println(i);
						out.flush();
						return;
					}
		}

		out.println("0");

		out.flush();
	}

}


import java.util.HashMap;
import java.util.Scanner;

public class Solution {
    public static void main(String [] args){
        Scanner in = new Scanner(System.in);

        String ins = in.nextLine();
        HashMap <String,Integer> sub = new HashMap<String,Integer>();
        for (int i=0;i<ins.length();i++){
            for (int j=i+1;j<=ins.length();j++){
                String key = ins.substring(i,j);
                if (sub.containsKey(key)){
                    sub.put(key,sub.get(key)+1);
                } else {
                    sub.put(key,1);
                }
            }
        }

        int max = 0;
        for (String key:sub.keySet()){
            if (sub.get(key) >= 2 && key.length() > max){
                max = key.length();
            }
        }

        System.out.print(max);
    }
}


import static java.util.Arrays.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import java.util.*;
import java.math.*;
import java.io.*;

public class A implements Runnable
{
    String file = "input";

    void init() throws IOException
    {
        //input = new BufferedReader(new FileReader(file + ".in"));
        input = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new BufferedOutputStream(System.out));
    }

    void solve() throws IOException
    {
        String s = next();
        int res = 0;
        int L = s.length();
        for(int i = 0; i < L; i++)
            for(int j = i + 1; j <= L; j++)
            {
                String ss = s.substring(i, j);
                int k = s.indexOf(ss);
                //print(ss, k);
                if(k >= 0)
                {
                    if(s.substring(k + 1).indexOf(ss) >= 0) res = max(res, j - i);
                }
            }
        System.out.println(res);
    }

    String next() throws IOException
    {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(input.readLine());
        return st.nextToken();
    }

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

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

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

    void print(Object... o)
    {
        System.out.println(deepToString(o));
    }

    void gcj(Object o)
    {
        String s = String.valueOf(o);
        out.println("Case #" + test + ": " + s);
        System.out.println("Case #" + test + ": " + s);
    }

    BufferedReader input;
    PrintWriter out;
    StringTokenizer st;
    int test;

    public static void main(String[] args) throws IOException
    {
        new Thread(null, new A(), "", 1 << 20).start();
    }

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


//package round23;

import java.io.PrintWriter;
import java.io.StringReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class A {
	private Scanner in;
	private PrintWriter out;
//	private String INPUT = add("a", 100);
	private String INPUT = "";

	public void solve()
	{
		String str = in.next();
		int n = str.length();
		for(int k = n - 1;k >= 1;k--){
			HashSet<String> set = new HashSet<String>();
			for(int i = 0;i < str.length() - k + 1;i++){
				if(!set.add(str.substring(i, i + k))){
					out.println(k);
					return;
				}
			}
		}
		out.println(0);
	}

	public void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new StringReader(INPUT));
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

	public static String add(String str, int k)
	{
		StringBuilder mul = new StringBuilder(str);
		StringBuilder ret = new StringBuilder();
		for(int i = k;i > 0;i >>= 1){
			if((i & 1) == 1)ret.append(mul);
			mul.append(mul);
		}
		return ret.toString();
	}

	public static void main(String[] args) throws Exception
	{
		new A().run();
	}

	private int ni() { return Integer.parseInt(in.next()); }
	private static void tr(Object... o) { System.out.println(o.length == 1 ? o[0] : Arrays.toString(o)); }
}


import java.io.*;
import java.util.*;
public class Answer23A{
    public static void main(String[] args){
	BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
	new Kai(reader).solve();
    }
}
class Kai{
    BufferedReader reader;
    public Kai(BufferedReader reader){
	this.reader=reader;
    }
    public void solve(){
	//TODO
	String s=read();
	int max=0;
	for(int i=1;i<=s.length()-1;i++){
	    for(int j=0;j<=s.length()-i;j++){
		String h=s.substring(j,j+i);
		for(int k=j+1;k<=s.length()-i;k++){
		    if(h.equals(s.substring(k,k+i))){
			max=i;
		    }
		}
	    }
	}
	pln(max);

    }
    //tools//////////////////////////////////////////////////
    public String read(){
	String s=null;
	try{
	    s=reader.readLine();
	}catch(IOException e){
	    e.printStackTrace();
	}
	return s;
    }
    public int[] to_i(String[] s){
	int[] tmp=new int[s.length];
	for(int i=0;i<s.length;i++){
	    tmp[i]=to_i(s[i]);
	}
	return tmp;
    }
    public long[] to_l(String[] s){
	long[] tmp=new long[s.length];
	for(int i=0;i<s.length;i++){
	    tmp[i]=to_l(s[i]);
	}
	return tmp;
    }
    public int to_i(String s){
	return Integer.parseInt(s);
    }
    public long to_l(String s){
	return Long.parseLong(s);
    }
    public void p(Object s){
	System.out.print(s);
    }
    public void pln(Object s){
	System.out.println(s);
    }
    public void debug(Object s){
	System.err.print(s);
    }
    public void debugln(Object s){
	System.err.println(s);
    }
}


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Scanner;

public class A {

    static {
	final Locale us = Locale.US;
	if (!Locale.getDefault().equals(us)) {
	    Locale.setDefault(us);
	}
    }

    static boolean file = false;

    static Scanner in;
    static {
	try {
	    in = new Scanner(file ? new FileInputStream("f:\\var\\tmp\\in.txt")
		    : System.in);
	} catch (final FileNotFoundException e) {
	    e.printStackTrace();
	}
    }

    static PrintWriter out;
    static {
	try {
	    out = file ? new PrintWriter(
		    new FileWriter("f:\\var\\tmp\\out.txt")) : new PrintWriter(
		    System.out);
	} catch (final IOException e) {
	    e.printStackTrace();
	}
    }

    /**
     * @param args
     */
    public static void main(final String[] args) {
	try {

	    solve();
	    if (file) {
		System.out.flush();
	    }
	    if (!file) {
		out.flush();
	    }

	} finally {
	    in.close();
	    out.close();
	}
    }

    private static void solve() {
	final String s = in.next();

	int ans = 0;
	for (int l = 0; l < s.length(); ++l) {
	    for (int r = l; r < s.length(); ++r) {
		for (int p = l + 1; p - l + r < s.length(); ++p) {
		    boolean ok = true;

		    for (int q = l, qq = p; q <= r; ++q, ++qq) {
			if (s.charAt(q) != s.charAt(qq)) {
			    ok = false;
			}
		    }

		    if (ok) {
			ans = Math.max(ans, r - l + 1);
		    }
		}
	    }
	}

	out.println(ans);
    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Gaurav
 */import java.io.*;
public class a23 {
    public static void main(String arg[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

          String s=br.readLine();int max=0;
          for(int i=0;i<s.length();i++)
          {
              for(int j=i+1;j<=s.length();j++)
              {
                  String g=s.substring(i,j);
                  //System.out.println(g);
                  if(max<g.length())
                  for(int k=i+1;k<=s.length()-g.length();k++)
                  {
                      //System.out.println(s.substring(k,k+g.length()));
                      if(g.compareTo(s.substring(k,k+g.length()))==0)
                      {
                          max=g.length();
                          break;
                      }
                      }
              }
          }
          System.out.println(max);
}
}


//contest 23. You're Given A String
import java.util.*;
public class ProblemA
{
	public static void main(String[] args)
	{
		Scanner keyboard = new Scanner(System.in);
		String input = keyboard.nextLine();
		boolean con = false;
		for( int i = input.length()-1; i > 0 ; i--)
		{
			for ( int j = 0; j+i< input.length(); j++ )
				for( int k = j+1; k+i <= input.length(); k++ )
					if( input.substring(j,j+i).equals( input.substring(k,k+i) ) )
					{
						System.out.print(i+"\n");
						k = input.length()+1;
						j = input.length();
						i = -1;
						con = true;
					}
		}
		if( con == false )
			System.out.print(0+"\n");
	}
}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class A{
    Scanner sc=new Scanner(System.in);

    void run(){
        String s=sc.nextLine();
        int n=s.length();
        int ans=0;
        for(int len=1; len<n; len++){
            for(int i=0; i+len<=n; i++){
                String t=s.substring(i, i+len);
//              println(t);
                if(s.indexOf(t,i+1)!=-1){
                    ans=len;
                    break;
                }
            }
        }
        println(ans+"");
    }

    void println(String s){
        System.out.println(s);
    }

    void print(String s){
        System.out.print(s);
    }

    public static void main(String[] args){
        new A().run();
    }

}


import java.util.Scanner;

public class P23A {
    public P23A() {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        sc.close();

        String maxStr = "";
        for (int i = 0; i < str.length() - 1; i++){
            for (int j = i + 1; j < str.length(); j++){
                String pattern = str.substring(i, j);
                if (str.substring(i+1).contains(pattern) && pattern.length() > maxStr.length()){
                    maxStr = pattern;
                }
            }
        }
        System.out.println(maxStr.length());
    }

    public static void main (String []args){
        new P23A();
    }
}


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

public class Test {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            for (int j = i + 1; j <= s.length(); j++) {
                String t = s.substring(i, j);
                if (s.indexOf(t, i + 1)>=0) {
                    ans = Math.max(ans, j - i);
                }
            }
        }
        System.out.println(ans);
    }

}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class R023A {
	String str;
	int n;
	public R023A() {
		Scanner scanner = new Scanner(System.in);
		str = scanner.next();
		n = str.length();
	}

	private void process() {
		int length = -1;
		for(int i=1; i<n; i++) {
			Set<String> set = new HashSet<String>();
			length = n - i;
			for(int j=0; j<=i; j++) {
				String sub = str.substring(j, j+length);
				set.add(sub);
			}
			if(set.size() < i+1) {
				System.out.println(length);
				return;
			}
		}
		System.out.println(0);
	}

	public static void main(String[] args) {
		new R023A().process();
	}
}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class A {
	public static void main(String[] args) throws Exception{
		String str = new Scanner(System.in).next();
		Set<String> set = new HashSet<String>();
		String max = "";
		for(int l = 1; l < str.length(); ++l){
			for(int i = 0; i < str.length()-l; ++i){
				String substr = str.substring(i, i+l);
				if(!set.contains(substr) && str.indexOf(substr) != str.lastIndexOf(substr)){
					set.add(substr);
					if(substr.length() > max.length()){
						max = substr;
					}
				}
			}
		}
		System.out.println(max.length());
	}

}


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class _P023A{
    Scanner sc=new Scanner(System.in);

    int INF=1<<28;
    double EPS=1e-9;

    String s;

    void run(){
        s=sc.nextLine();
        solve();
    }

    void solve(){
        int n=s.length();
        int max=0;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                for(int k=0; j+k<n; k++){
                    if(s.charAt(i+k)!=s.charAt(j+k)){
                        break;
                    }else{
                        max=max(max, k+1);
                    }
                }
            }
        }
        println(max+"");
    }

    void println(String s){
        System.out.println(s);
    }

    void print(String s){
        System.out.print(s);
    }

    void debug(Object... os){
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args){
        Locale.setDefault(Locale.US);
        new _P023A().run();
    }
}


/**
 * Mx NINJA 04:06:52 ص 14/01/2014
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder line = new StringBuilder(reader.readLine());
        int length = 0;
        for (int head = 0; head < line.length(); head++) {
            for (int tail = line.length() - 1; tail > head; tail--) {
                String subString = line.substring(head, tail);
                if(line.indexOf(subString,head+1)>-1){
                    length = Math.max(subString.length(), length);
                }
            }
        }
        System.out.println(length);
    }
}


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

public class A implements Runnable {
	public static void main(String[] args) {
		new A().run();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		boolean eof;
		String buf;

		public FastScanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
			nextToken();
		}

		public FastScanner(InputStream stream) {
			br = new BufferedReader(new InputStreamReader(stream));
			nextToken();
		}

		String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		void close() {
			try {
				br.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	void solve() {
		String s = nextToken();
		for (int len = s.length(); len >= 1; len--) {
			for (int i = 0; i + len <= s.length(); i++) {
				int cnt = 0;
				for (int j = 0; j + len <= s.length(); j++) {
					boolean ok = true;
					for (int k = 0; k < len; k++) {
						if (s.charAt(i + k) != s.charAt(j + k)) {
							ok = false;
							break;
						}
					}
					if (ok) {
						cnt++;
					}
				}
				if (cnt > 1) {
					out.println(len);
					return;
				}
			}
		}
		out.println(0);
	}
}


import java.util.Scanner;

public class GiveString23A {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        String stroke = in.next();
        char[] s = new char [stroke.length()];
        for (int i=0;i<stroke.length();i++)
            s[i]=stroke.charAt(i);
        int dlina = 0;
        for (int i=0;i<s.length-1;i++)
            for (int j=i+1;j<s.length;j++)
                for (int k=0;k<(s.length-j);k++)
                    if (s[i]==s[j])
                    {
                        int ik=i+k;
                        int jk = j+k;
                        if (s[ik]==s[jk])
                        {
                            if (dlina<k+1)
                                dlina=k+1;
                        }
                        else
                        break;
                    }
        System.out.println(dlina);
    }
}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class P023A {

    public static void main(String[] args) {
        Scanner inScanner = new Scanner(System.in);
        String string = inScanner.next();
        int n = string.length();
        for (int l = n - 1; l > 0; l--) {
            Set<String> seen = new HashSet<String>();
            for (int i = 0; i < n - l + 1; i++) {
                String subString = string.substring(i, i + l);
                if (seen.contains(subString)) {
                    System.out.println(l);
                    return;
                }
                seen.add(subString);
            }
        }
        System.out.println("0");
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;

/**
 * @author Egor Kulikov (egor@egork.net)
 *         Created on 14.03.2010
 */
public class TaskA implements Runnable {
	private InputReader in;
	private PrintWriter out;

	public static void main(String[] args) {
		new Thread(new TaskA()).start();
//		new Template().run();
	}

	public TaskA() {
//		String id = getClass().getName().toLowerCase();
//		try {
//			System.setIn(new FileInputStream(id + ".in"));
//			System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//			System.setIn(new FileInputStream("input.txt"));
//			System.setOut(new PrintStream(new FileOutputStream("output.txt")));
//		} catch (FileNotFoundException e) {
//			throw new RuntimeException();
//		}
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
	}

	public void run() {
//        int numTests = in.readInt();
//        for (int testNumber = 0; testNumber < numTests; testNumber++) {
//			out.print("Case " + (testNumber + 1) + ": ");
//        }
		String s = in.readString();
		Set<String> m = new HashSet<String>();
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			for (int j = i + 1; j <= s.length(); j++) {
				if (m.contains(s.substring(i, j)))
					ans = Math.max(ans, j - i);
				else
					m.add(s.substring(i, j));
			}
		}
		out.print(ans);
		out.close();
	}

	private static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1000];
		private int curChar, numChars;

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

		private 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 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 String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuffer res = new StringBuffer();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private String readLine0() {
			StringBuffer buf = new StringBuffer();
			int c = read();
			while (c != '\n' && c != -1) {
				buf.appendCodePoint(c);
				c = read();
			}
			return buf.toString();
		}

		public String readLine() {
			String s = readLine0();
			while (s.trim().length() == 0)
				s = readLine0();
			return s;
		}

		public String readLine(boolean ignoreEmptyLines) {
			if (ignoreEmptyLines)
				return readLine();
			else
				return readLine0();
		}

		public BigInteger readBigInteger() {
			try {
				return new BigInteger(readString());
			} catch (NumberFormatException e) {
				throw new InputMismatchException();
			}
		}

		public char readCharacter() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			return (char) c;
		}

		public double readDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
	}
}


import java.text.DecimalFormat;
import java.util.Scanner;

public class A {
    public static void main(String[] args){
        try{
            Scanner scanner = new Scanner(System.in);
            String in = scanner.next();
            int max = 0;
            for(int j=0;j<in.length()-1;j++){
                for(int i=j;i<in.length();i++){
                    if(in.indexOf(in.substring(j, i)) != in.lastIndexOf(in.substring(j, i)) && (i-j)>max){
                        max = i-j;
                    }
                }
            }
            System.out.println(max);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class Solution23A {

        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
                if (ONLINE_JUDGE){
                        in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
                }else{
                        in = new BufferedReader(new FileReader("input.txt"));
                        out = new PrintWriter("output.txt");
                }
        }

        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        tok = new StringTokenizer(in.readLine());
                }
                return tok.nextToken();
        }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }

        long readLong() throws IOException{
                return Long.parseLong(readString());
        }

        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }

        public static void main(String[] args){
                new Solution23A().run();
        }

        public void run(){
                try{
                        long t1 = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = "+(t2-t1));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

        void solve() throws IOException{
        	char[] t = readString().toCharArray();
        	int max = 0;
        	for(int i = 0; i < t.length; i++){
        		for(int j = i + 1; j < t.length; j++){
        			for(int k = 0; k < t.length - j; k++){
        				if(t[i+k] == t[j+k]) max = max(max, k+1);
        				else break;
        			}
        		}
        	}
        	out.println(max);
        }

        int ModExp(int a, int n, int mod){
        	int res = 1;
        	while (n!=0)
        		if ((n & 1) != 0) {
        			res = (res*a)%mod;
        			--n;
        		}
        		else {
        			a = (a*a)%mod;
        			n >>= 1;
        		}
        	return res;
        }

        static class Utils {

                private Utils() {}

                public static void mergeSort(int[] a) {
                        mergeSort(a, 0, a.length - 1);
                }

                private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
                        final int MAGIC_VALUE = 50;
                        if (leftIndex < rightIndex) {
                                if (rightIndex - leftIndex <= MAGIC_VALUE) {
                                        insertionSort(a, leftIndex, rightIndex);
                                } else {
                                        int middleIndex = (leftIndex + rightIndex) / 2;
                                        mergeSort(a, leftIndex, middleIndex);
                                        mergeSort(a, middleIndex + 1, rightIndex);
                                        merge(a, leftIndex, middleIndex, rightIndex);
                                }
                        }
                }

                private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
                        int length1 = middleIndex - leftIndex + 1;
                        int length2 = rightIndex - middleIndex;
                        int[] leftArray = new int[length1];
                        int[] rightArray = new int[length2];
                        System.arraycopy(a, leftIndex, leftArray, 0, length1);
                        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
                        for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                                if (i == length1) {
                                        a[k] = rightArray[j++];
                                } else if (j == length2) {
                                        a[k] = leftArray[i++];
                                } else {
                                        a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                                }
                        }
                }

                private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
                        for (int i = leftIndex + 1; i <= rightIndex; i++) {
                                int current = a[i];
                                int j = i - 1;
                                while (j >= leftIndex && a[j] > current) {
                                        a[j + 1] = a[j];
                                        j--;
                                }
                                a[j + 1] = current;
                        }
                }
        }

        boolean isPrime(int a){
        	for(int i = 2; i <= sqrt(a); i++)
        		if(a % i == 0) return false;
        	return true;
        }

        static double distance(long x1, long y1, long x2, long y2){
        	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }

        static long gcd(long a, long b){
        	if(min(a,b) == 0) return max(a,b);
        	return gcd(max(a, b) % min(a,b), min(a,b));
        }

        static long lcm(long a, long b){
        	return a * b /gcd(a, b);
        }
}


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

/**
 *
 * @author Prateep
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
    }
}

class TaskB{
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String base = in.next();
    for (int len=base.length()-1;len>=1;len--)
            for (int i=0;i<base.length()-len+1;i++)
                for (int j=i+1;j<base.length()-len+1;j++)
                    if (base.substring(i,i+len).equals(base.substring(j,j+len))){
                        out.println(len);
            return;
                    }
    out.println(0);

    }

}
class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong(){
        return Long.parseLong(next());
    }
    public double nextDouble(){
        return Double.parseDouble(next());
    }
}


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

public class A implements Runnable {

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public static void main(String[] args) {
		new Thread(new A()).start();
	}

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException {
		String s = nextToken();
		int max = 0;
		for(int i = 0 ; i < s.length(); i++)
			for(int j = i+1 ; j < s.length(); j ++){
				String sub = s.substring(i, j);
				int kv = 0;
				for(int k = 0 ; k<= s.length() - sub.length(); k ++){
					boolean ok = true;
					for(int g = 0 ; g < sub.length(); g ++)
					if (sub.charAt(g) != s.charAt(g+k)){
						ok = false;
						break;
					}
					if (ok) kv ++;
				}
				if (kv > 1)
				max = Math.max(max, sub.length());
			}

		out.println(max);
	}

	public void run() {
		try {
				br = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);

		//		br = new BufferedReader(new FileReader("input.txt"));
		//		out = new PrintWriter("output.txt");

			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}

	}

}


import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.io.*;

public class Mulitple
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

		String s = r.readLine();

		System.out.println(num(s));
	}

	public static int num(String s)
	{
		int answer = 0;
		Set<String> set = new HashSet<String>();
		for(int j = s.length()-1; j>=1; j--)
		{
			for(int i = 0; i<s.length()-j+1; i++)
			{
				if(set.contains(s.substring(i,i+j)))
				{
					return s.substring(i,i+j).length();
				}
				else
				{
					set.add(s.substring(i,i+j));
				}
			}
		}

		return 0;

	}
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.Math.*;

public class Main {
    //StreamTokenizer in;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        //in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));

        String s = in.readLine();
        int n = s.length();
        for(int len = n; len > 0; len--) {
            for(int i = 0; i + len <= n; i++) {
                for(int j = 0; j + len <= n; j++)
                    if(i != j) {
                        boolean f = true;
                        for(int k = 0; k < len; k++)
                            if(s.charAt(i + k) != s.charAt(j + k)) {
                                f = false;
                                break;
                            }
                        if(f) {
                            out.println(len);
                            out.flush();
                            return;
                        }
                    }
            }
        }
        out.println(0);
        out.flush();
    }

    void solve() throws IOException {

    }

    //int ni() throws IOException { in.nextToken(); return (int) in.nval; }
}


import static java.lang.Math.max;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class GivenString implements Runnable
{
  public static void main(String[] args) throws Exception
  {
    new GivenString().run();
  }

  private void solve() throws Exception
  {
    String s = nextToken();
    int len = s.length();
    KMP kmp = new KMP();
    int r = 0;
    for (int i = 0; i < len; i++)
    {
      for (int j = i + 1; j <= len; j++)
      {
        String cur = s.substring(i, j);
        int count = kmp.search(s, cur);
        if (count >= 2)
          r = max(r, cur.length());
      }
    }
    out.println(r);
  }

  class KMP
  {
    public int search(String text, String pattern)
    {
      int count = 0;
      int n = text.length(), m = pattern.length(), matchPoint = -1;
      char pat[] = pattern.toCharArray(), t[] = text.toCharArray();
      int p[] = prefixTable(pattern);
      int j = 0;
      for (int i = 0; i < n; i++)
      {
        while (j > 0 && pat[j] != t[i])
          j = p[j - 1];
        if (pat[j] == t[i])
          j++;
        if (j == m)
        {
          matchPoint = i - m + 1;
          j = p[j - 1];
          count++;
        }
      }
      return count;
    }

    private int[] prefixTable(String pat)
    {
      int m = pat.length(), p[] = new int[m];
      char s[] = pat.toCharArray();
      int j = 0;
      for (int i = 1; i < m; i++)
      {
        while (j > 0 && s[j] != s[i])
          j = p[j - 1];
        if (s[j] == s[i])
          j++;
        p[i] = j;
      }
      return p;
    }

  }

  // -------------- Input/Output routines below ---------------//
  private BufferedReader in;
  PrintWriter out;
  StringTokenizer tokenizer;

  public void run()
  {
    // String problem = this.getClass().getName();
    try
    {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new BufferedOutputStream(System.out));
      solve();
      out.flush();
      in.close();
      out.close();
    }
    catch (Exception e)
    {
      e.printStackTrace();
      // System.exit(1);
    }
  }

  String nextToken() throws IOException
  {
    while (tokenizer == null || !tokenizer.hasMoreTokens())
    {
      tokenizer = new StringTokenizer(in.readLine());
    }
    return tokenizer.nextToken();
  }

  int nextInt() throws IOException
  {
    return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException
  {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException
  {
    return Double.parseDouble(nextToken());
  }

}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main{
    private static Parser in;
    private static PrintWriter out;

    public static void main(String[] args){
        in = new Parser(System.in);
        out = new PrintWriter(System.out);

//
//        char[] ccc = new char[1];
//        String ddd = "abcdef";
//        ddd.getChars(2, 3, ccc, 0);
//
//        String sssss = new String(ccc);
//
//        System.out.println(sssss);
//
        String s = in.nextString(100);
        int len = 0;
        String ss = "";

        l:for (int i = 1; i<=s.length(); i++){
            for(int j = 0; j+i<=s.length();j++){
                char[] c = new char[i];
                char[] cc = new char[i];
                s.getChars(j, j+i, c, 0);
                String sss = new String(c);
                //System.out.println(sss);
                for(int k = j+1; k+i<=s.length();k++){

                    s.getChars(k, k+i, cc, 0);
                    String ssss = new String(cc);
                    if(sss.equals(ssss)) {len = i; continue l;}
                }
            }
        }

        System.out.println(len);
       // out.flush();
    }
}

class Parser {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Parser(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
    }
    public String nextString(int size) {
        byte[] ch = new byte[size];
        int point = 0;
        try {
            byte c = read();
            while (c == ' ' || c == '\n' || c=='\r')
                c = read();
            while (c != ' ' && c != '\n' && c!='\r') {
                ch[point++] = c;
                c = read();
            }
        } catch (Exception e) {}
        return new String(ch,0,point);
        }
    public int nextInt() {
    int ret = 0;
    boolean neg;
    try {
        byte c = read();
        while (c <= ' ')
            c = read();
        neg = c == '-';
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
            c = read();
        } while (c > ' ');

    if (neg) return -ret;
    } catch (Exception e) {}
    return ret;
    }
    public long nextLong() {
        long ret = 0;
        boolean neg;
        try {
            byte c = read();
            while (c <= ' ')
                c = read();
            neg = c == '-';
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
                c = read();
            } while (c > ' ');

        if (neg) return -ret;
        } catch (Exception e) {}
        return ret;
        }
    private void fillBuffer() {
        try {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        } catch (Exception e) {}
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }
}


/**
 * Created by IntelliJ IDEA.
 * User: shakhov
 * Date: 15.06.2011
 * Time: 15:22:46
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class CodeForces {

    public void solve() throws IOException {
        String s = nextToken();
        Set<String> set = new HashSet<String>();
        int counter = 0;
        for (int i = 0, l = s.length(); i < l; i++) {
            for (int j = i + 1; j < l; j++) {
                String subst = s.substring(i, j);
                if (!set.contains(subst)) {
                    set.add(subst);
                    if (counts(s.toCharArray(), subst.toCharArray()) > 1) {
                        counter = Math.max(counter, subst.length());
                    }

                }
            }
        }

        writer.print(counter);

    }

    private int counts(char[] s, char[] r) {
        int l = s.length;
        int rl = r.length;
        int arr[] = new int[26];
        Arrays.fill(arr, rl);
        for (int i = rl - 2; i > -1; i--) {
            int margin = (r[i] - 'a');
            if (arr[margin] == rl) {
                arr[margin] = rl - i - 1;
            }
        }
        //search
        int sp = 0;
        int counter = 0;
        while (sp <= l - rl) {
            int oldsp = sp;
            for (int i = rl - 1; i > -1; i--) {
                if (r[i] != s[sp + i]) {
                    if (i == rl - 1) {
                        sp += arr[s[sp + i] - 'a'];

                    } else {
                        sp++;
                    }
                    break;
                }
            }
            if (oldsp == sp) {
                counter++;
                sp++;
            }
        }
        return counter;
    }

    public static void main(String[] args) {
        new CodeForces().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            //reader = new BufferedReader(new FileReader("LifeWithoutZeros.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            //writer = new PrintWriter(new BufferedWriter(new FileWriter("LifeWithoutZeros.out")));
            //long t=new Date().getTime();
            solve();
            //writer.println(t-new Date().getTime());
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


import java.util.Scanner;

public class p23a {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] x = in.next().toCharArray();

        int min = 0;
        int max = x.length;
        while(true) {
            if(max-min == 1)
                break;
            int mid = (max+min)/2;
            boolean eq = false;
            for (int i = 0; i <= x.length-mid; i++) {
                for (int j = 0; j <= x.length-mid; j++) {
                    if(j == i)
                        continue;
                    eq = true;
                    for (int k = 0; k < mid; k++) {
                        if(x[i+k] != x[j+k]) {
                            eq = false;
                            break;
                        }
                    }
                    if(eq)
                        break;
                }
                if(eq) break;
            }
            if(eq) {
                min = mid;
            } else {
                max = mid;
            }
        }
        System.out.println(min);

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A23 implements Runnable {

	private void Solution() throws IOException {
		String s = in.readLine();
		int n = s.length(), ans = 0;
		for (int i = 0; i < n; i ++) {
			for (int j = i; j < n; j ++) {
				for (int k = i+1; k <= n; k ++) {
					for (int g = k; g <= n; g ++) {
						if (s.substring(i,j).equals(s.substring(k,g))) {
							int l = s.substring(i,j).length();
							ans = Math.max(ans, l);
						}
					}
				}
			}
		}
		System.out.println(ans);
	}

	public static void main(String args[]) {
		new A23().run();
	}

	BufferedReader in;
	StringTokenizer tokenizer;

	public void run() {
		try {
            in = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            Solution();
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CodeF
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextDouble();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public String[] nextStringArray(int n)
		{
			String[] vals = new String[n];
			for(int i = 0; i < n; i++)
				vals[i] = next();
			return vals;
		}

		Integer nextInteger()
		{
			String s = next();
			if(s == null)
				return null;
			return Integer.parseInt(s);
		}

		int[][] nextIntMatrix(int n, int m)
		{
			int[][] ans = new int[n][];
			for(int i = 0; i < n; i++)
				ans[i] = nextIntArray(m);
			return ans;
		}
	}

	static int[] compute_prefix_function(char[] p) {
	    int[] pi = new int[p.length]; pi[0] = -1; int k = -1;
	    for (int i = 1; i < p.length; i++) {
	        while (k >= 0 && p[k + 1] != p[i]) k = pi[k];
	        if (p[k + 1] == p[i]) k++; pi[i] = k;
	    }
	    return pi;
	}

	static boolean KMP_Matcher(String pattern, String text) {
	    char[] p = pattern.toCharArray(); char[] t = text.toCharArray();
	    int[] pi = compute_prefix_function(p); int q = -1;
	    int cuenta = 0;
	    for (int i = 0; i < text.length(); i++) {
	        while (q >= 0 && p[q + 1] != t[i]) q = pi[q];
	        if (p[q + 1] == t[i]) q++;
	        if (q == p.length - 1) {
	            cuenta++;
	            q = pi[q];
	        }
	    }
	    return cuenta >= 2;
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		String entrada = sc.next();
		int mejor = 0;
		for(int i = 0; i < entrada.length(); i++)
		{
			for(int j = i + 1; j <= entrada.length(); j++)
			{
				String sub = entrada.substring(i, j);
				if(KMP_Matcher(sub, entrada))
					mejor = Math.max(j - i, mejor);
			}
		}
		System.out.println(mejor);
	}
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class ProblemA_23 {

    final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok=new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in=new BufferedReader(new InputStreamReader(System.in));
            out =new PrintWriter(System.out);
        }
        else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            tok=new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        new ProblemA_23().run();
    }

    public void run(){
        try{
            long t1=System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2=System.currentTimeMillis();
            System.err.println("Time = "+(t2-t1));
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    void solve() throws IOException{
        String s = readString();
        for (int length = s.length() - 1; length > 0; length--){
            for (int i = 0; i < s.length() - length; i++){
                if (s.lastIndexOf(s.substring(i, i + length)) > i){
                    out.print(length);
                    return;
                }
            }
        }
        out.print(0);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class A {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
		int len=s.length();
		int ans=0;
		for (int i=0;i<len-1;i++) {
			for (int j=i+1;j<len;j++) {
				int score=0;
				boolean flag=true;
				for (int k=0;k+j<len && flag;k++) {
					if (s.charAt(i+k)==s.charAt(j+k)) {
						score++;
					} else {
						flag=false;
					}
				}
				if (score>ans) {
					ans=score;
				}
			}
		}
		System.out.println(ans);
	}
}


import java.util.*;
public class P023A {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        String line = in.next();

        HashSet<String> hash = new HashSet<String>();

        int ans = 0;
        for (int len = line.length()-1; len > 0; --len)
        {
            for (int i = 0; i + len <= line.length(); ++i)
            {
                String sub = line.substring(i, i+len);
                if (hash.contains(sub))
                {
                    ans = Math.max(ans, sub.length());
                }

                hash.add(sub);
            }
        }

        System.out.println(ans);
    }
}


import java.util.*;

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

public class Main {

	boolean test = false;
	PrintWriter pw = new PrintWriter(System.out);
	InputStreamReader inp = new InputStreamReader(System.in);
	BufferedReader in = new BufferedReader(inp);

	private String[] inData = {"zzz"
			};

	static int id = -1;

	public String readLine() {
		id++;
		if (test)
			return inData[id];
		else
			try{
				return in.readLine();
			} catch( Exception e){
				e.printStackTrace();
			}
		return "";
	}

	private void solve() {

		String readLine = readLine();

		int best = 0;

		for (int i = 0; i < readLine.length(); i++) {
			for (int j = i; j < readLine.length(); j++) {
				String substring = readLine.substring(i,j+1);
				String remainString = readLine.substring(i+1);
				if(remainString.contains(substring)){
					if(substring.length() > best){
						best = substring.length();
					}

				}
			}
		}
		System.out.println(best);
	}

	public static void main(String args[]) throws Exception {

		new Main().solve();
    }

}


import java.util.Scanner;
public class x23A {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		//input+="3";
		int longest=0;
		if(input.length()==1){
			System.out.println(0);
			System.exit(0);
		}
		if(input.length()==2){
			if(input.charAt(0)==input.charAt(1)){
				System.out.println(1);
				System.exit(0);
			}
			else{
			System.out.println(0);
			System.exit(0);}
		}
		for(int a=0;a<input.length()-1;a++){
			for(int b=a+1;b<input.length();b++){
				for(int c=1;(c+b)<input.length()+1;c++){
				//	System.out.printf("%s %s %d\n", input.substring(a,a+c), input.substring(b,b+c), input.substring(a,a+c).compareTo(input.substring(b,b+c)));
					if(input.substring(a,a+c).compareTo(input.substring(b,b+c))==0)
					if(longest<c)longest=c;
				}
			}
		}
		System.out.println(longest);
		}
	}