source_code: 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);
  	}
  }