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