using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace codeforces
{
    class C
    {
        static CodeforcesUtils CF = new CodeforcesUtils(
@"
zzzzzzzzzzzzzzzzzzzz
");

        static void Main(string[] args)
        {
            string s = CF.ReadLine();

            int max = 0;
            for (int i = 1; i < s.Length; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    int len = 0;
                    for (;i+len<s.Length ;len++ )
                    {
                        if (s[i + len] != s[j + len])
                            break;
                    }
                    if (len > max)
                        max = len;
                }
            }
            CF.WriteLine(max);
        }

        #region test

        class CodeforcesUtils
        {
            public string ReadLine()
            {
#if DEBUG
                if (_lines == null)
                {
                    _lines = new List<string>();
                    string[] ss = _test_input.Replace("\n", "").Split('\r');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (
                            (i == 0 || i == ss.Length - 1) &&
                            ss[i].Length == 0
                            )
                            continue;

                        _lines.Add(ss[i]);
                    }
                }

                string s = null;
                if (_lines.Count > 0)
                {
                    s = _lines[0];
                    _lines.RemoveAt(0);
                }
                return s;
#else
            return Console.In.ReadLine();
#endif
            }

            public void WriteLine(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
            }

            public void Write(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
            }

            public CodeforcesUtils(string test_input)
            {
                _test_input = test_input;
            }

            string _test_input;

            List<string> _lines;
        }

        #endregion
    }
}

using System;

namespace Task23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int ans = 0;
            for (int start = 0; start < input.Length - 1; start++)
            {

                for (int count = 1; count < input.Length; count++)
                {
                    for (int inner = start+1;inner <= input.Length - count ; inner++ )
                    {
                        if (
                            input.Substring(start, count).Equals(input.Substring(inner, count))
                            ) ans = count > ans ? count : ans;
                    }
                }

            }

            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

namespace FirstApp
{

    class Program
    {

        static void Main(string[] args)
        {

            string[] substr = new string[10000];

            int[] count = new int[10000];

            int num = 0;

            string str = Console.ReadLine();
           // string str = "ckvfndqgkmhcyojaqgdkenmbexufryhqejdhctxujmtrwkpbqxufxamgoeigzfyzbhevpbkvviwntdhqscvkmphnkkljizndnbjt";

            bool check;

            for (int i = 0; i < 10000; i++)
            {

                count[i] = 0;

            }

            for (var i = 0; i < str.Length; i++)
            {

                StringBuilder tmp = new StringBuilder("", 1000);

                for (var j = i; j < str.Length; j++)
                {

                    tmp.AppendFormat(Convert.ToString(str[j]));

                        //проверяем есть ли значение в массиве подстрок

                        check = true;
                    /*
                        for (var m = 0; m < num; m++)
                        {
                            if (String.Compare(Convert.ToString(tmp), Convert.ToString(substr[m]), true) == 0)
                            {
                                check = false;
                                break;
                            }
                        }
                    */
                        //проверяем на уникальность и добавим в массив подстроки

                    if (check == true)
                    {
                        substr[num] = Convert.ToString(tmp);
                        num++;
                    }
                }

            }

            //начинаем поиск

            for (var r = 0; r < num; r++)
            {
                int pos = -1; //позиция

                for (int st = 0; st < str.Length; st++)
                {
                    int index = str.IndexOf(substr[r], st);

                    if (index > -1 && pos != index)
                    {
                        count[r] = count[r] + 1;
                        pos = index;

                    }
                }
            }

            //отбираем самую большую подстроку

            int symcount = 0;
            for (var r = 0; r < num; r++)
            {
                if (count[r] > 1)
                {
                   // Console.WriteLine(count[r]);
                    if (substr[r].Length > symcount)
                    {
                        symcount = substr[r].Length;
                    }
                }
            }

            Console.WriteLine(symcount);

           // Console.WriteLine("end");
          //  Console.ReadKey();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace CodeForce
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            var listSample = new List<string>();

            var result = 0;

            for (int i = 1; i <= input.Length; i++)
            {
                for (int j = 0; j < input.Length; j++)
                {
                    if (j + i <= input.Length)
                        listSample.Add(input.Substring(j, i));
                    else break;
                }
            }

            var selectItem = (from res in listSample
                              where listSample.Count(y => res == y) > 1
                              select res).Distinct();

            foreach (var item in selectItem)
            {
                if (item.ToString().Length > result)
                {
                    result = item.ToString().Length;
                }
            }

            Console.WriteLine(result);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int n = a.Length;
            int res = 0;
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    string s = a.Substring(j, i - j + 1);
                    string ss = a.Substring(j + 1);
                    if (ss.Contains(s))
                    {
                        res = Math.Max(res, s.Length);
                    }
                }
            }
            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int n = line.Length - 1;
            Dictionary<string, int> d = new Dictionary<string, int>();

            while (n > 0)
            {
                List<String> list = Split(line, n);

                foreach (String s in list)
                {
                    int o = Occurs(line, s);
                    if (o >= 2)
                    {
                        d.Add(s, o);
                    }
                }

                n--;
            }

            if (d.Count > 0)
            {

                int max = 0;
                string temp = "";

                foreach (String s in d.Keys)
                {
                    if (s.Length > max)
                    {
                        max = s.Length;
                        temp = s;
                    }
                }

                Console.WriteLine(temp.Length);
            }
            else
                Console.WriteLine("0");

        }

        static List<String> Split(string input,int n)
        {
            List<String> list = new List<string>();
            int counter = 0;

            while (counter+n <= input.Length)
            {
                if (!list.Contains(input.Substring(counter, n)))
                {
                    list.Add(input.Substring(counter, n));

                }
                counter++;

            }

            return list;
        }

        static int Occurs(string input,string sub)
        {
            int counter = 0;
            int count = 0;
            while (counter + sub.Length <= input.Length)
            {
                if (input.Substring(counter, sub.Length) == sub)
                {
                    count++;
                }
                counter++;
            }
            return count;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
           // string str = "ababa";
            string tmpStr;
            string podstr;
            string otvet = "^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for (int g = 1; g < str.Length - i; g++)
                {

                    tmpStr = str.Substring(i + 1);
                    podstr = str.Substring(i, g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if (otvet.Length <= podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round19
{
    class B
    {
        public static void Main()
        {
            string s = Console.ReadLine();
            for (int i = s.Length - 1; i > 0; i--)
            {
                int n = s.Length - i + 1;
                for (int j = 0; j < n; j++)
                {
                    string ss = s.Substring(j, i);
                    int count = 0;
                    for (int k = 0; k < n; k++)
                        if (s.Substring(k, i) == ss)
                            count++;
                    if (count >= 2)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }
            Console.WriteLine(0);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForce
{
    class _23a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var z = 0;
            for (var i = line.Length - 1; i > 0; i--)
            {
                z++;
                for (var j = 0; j < z; j++)
                {
                    var str = line.Substring(j, i);
                    if (line.IndexOf(str, j + 1) >= 0)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }
            Console.WriteLine(0);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Numerics;
using System.Globalization;

namespace JalalHani
{
    class Vertex
    {
        public List<int> relations = new List<int>();
        public List<int> weights = new List<int>();
        public Vertex(int r , int w)
        {
            this.relations.Add(r);
            this.weights.Add(w);
        }
        public void AddInfo (int r, int w)
        {
            this.relations.Add(r);
            this.weights.Add(w);
        }
        ////Dijkstra
        //int[] data = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        //int n = data[0], m = data[1];
        //Dictionary<int, Vertex> Edges = new Dictionary<int, Vertex>();
        //for (int i = 0; i < m; i++)
        //{
        //    data = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        //    int k = data[0], r = data[1], w = data[2];
        //    if (Edges.Keys.Contains(k))
        //    {
        //        Edges[k].AddInfo(r,w);
        //    }
        //    else
        //    {
        //        Edges.Add(k, new Vertex(r, w));
        //    }
        //}

        //foreach (var edge in Edges)
        //{

        //}
    }

    class Program
    {

        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long o = 0;
            List<string> rep = new List<string>();

            for (int length = 1; length < s.Length; length++)
            {
                for (int j = 0; j <= s.Length-length; j++)
                {
                    string subS = s.Substring(j, length);
                    bool u = SearchInSubstring(s,subS,j,length);
                    if (u)
                    {
                        rep.Add(subS);
                    }
                }
            }
            if (rep.Count > 0)
            o = rep.Select(x => x.Length).Max();
            Console.WriteLine(o);
        }

        static bool SearchInSubstring (string source, string cut,int indexStart, int EndString) {
            bool found = false;
            char[] src = source.ToCharArray();
            src[indexStart] = '#';

            found = string.Join("", src).Contains(cut);

            return found;
        }

        static int Test(int v , int m)
        {
            int p1 = 0;
            int dif = (int)Math.Ceiling((double)m / v);
            int diff = v * dif;
            p1 = (diff - m);
            p1 += dif == 2 ? 1 : dif;

            return p1;
        }

        static void MulticasesQuestion()
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
                SolveTestCase();
        }
        static void SolveTestCase()
        {

        }
        static int GCD(int a1, int a2)
        {
            int mx = Math.Max(a1, a2);
            int mn = Math.Min(a1, a2);

            if (mx % mn == 0)
            {
                return mn;
            }
            else GCD(mn, mx % mn);
            return 1;
        }

        static BigInteger Pow(int b, int a)
        {
            BigInteger x = 1;

            for (int i = 0; i < a; i++)
            {
                x *= b;
            }

            return x;
        }
        static void LeastCostBracketSequence()
        {
            var input = Console.ReadLine().ToCharArray();
            var isSolutionExists = true;
            long totalCost = 0;
            var balance = 0;

            var sortedVariants = new List<Variant>();
            var comparer = new ByCostSwitch();

            for (var i = 0; i < input.Length; i++)
            {
                if (input[i] == '(')
                {
                    balance++;
                }
                else if (input[i] == ')')
                {
                    balance--;
                }
                else
                {
                    var costValue = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
                    var variant = new Variant()
                    {
                        CostSwitch = costValue[0] - costValue[1],
                        Position = i
                    };

                    var index = sortedVariants.BinarySearch(variant, comparer);
                    if (index < 0)
                    {
                        index = ~index;
                    }

                    sortedVariants.Insert(index, variant);

                    totalCost += costValue[1];
                    balance--;
                }

                if (balance < 0)
                {
                    if (sortedVariants.Count == 0)
                    {
                        isSolutionExists = false;
                        break;
                    }

                    var sortedVariant = sortedVariants[0];

                    input[sortedVariant.Position] = '(';
                    totalCost += sortedVariant.CostSwitch;
                    balance += 2;
                    sortedVariants.RemoveAt(0);
                }
            }

            isSolutionExists = (balance == 0);

            if (isSolutionExists)
            {
                Console.WriteLine(totalCost);
                for (var i = 0; i < input.Length; i++)
                {
                    if (input[i] == '?')
                    {
                        Console.Write(')');
                    }
                    else
                    {
                        Console.Write(input[i]);
                    }
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
        class Commands
        {
            public static int[] NextIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).ToArray();
                }
            }
            public static List<int> NextIntList
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).ToList();
                }
            }
            public static int[] NextSortedIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
                }
            }
            public static int[] NextDescSortedIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
                }
            }
            public static long[] NextLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).ToArray();
                }
            }
            public static List<long> NextLongList
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).ToList();
                }
            }
            public static long[] NextSortedLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
                }
            }
            public static long[] NextDescSortedLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
                }
            }
            public static int NextInt
            {
                get
                {
                    return int.Parse(Console.ReadLine());
                }
            }

            public static string NextString
            {
                get { return Console.ReadLine(); }
            }
        }

        private class Variant
        {
            public int CostSwitch;
            public int Position;
        }

        private class ByCostSwitch : IComparer<Variant>
        {
            #region IComparer implementation
            public int Compare(Variant x, Variant y)
            {
                return x.CostSwitch.CompareTo(y.CostSwitch);
            }
            #endregion
        }
    }
}

using System;
/*
 abcde
i==0
 a => {b ,c, d,e}   subLen=1
 ab => {bc, cd, de} subLen=2
 abc => {bcd,cde }  subLen=3
 abcd =>{bcde}      subLen=4
i==1
 b=> {c, d,e}    subLen=1
 bc => {cd, de}  subLen=2
 bcd => {cde}    subLen=3
i==2
 c =>  { d, e}   subLen=1
 cd => {de}      subLen=2
i==3
 d => {e}       subLen=1

 01234
"abcde"  length=5   s.Substring(i, subLen)
a
ab
abc
abcd
abcde
b
bc
bcd
bcde
c
cd
cde
d
de
e
     */
namespace Task_23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int sLen = s.Length, ans = 0;
            for (int i = 0; i < sLen - 1; i++)
            {
                for (int subLen = 1; subLen <= sLen - i; subLen++)
                {
                    for (int j = i + 1; j <= sLen-subLen; j++)
                    {
                        string sub1 = s.Substring(i, subLen);
                        string sub2 = s.Substring(j, subLen);

                        if (sub1.Equals(sub2) && ans < subLen)
                            ans = subLen;
                    }

                }

            }

            Console.WriteLine(ans);
        }
    }
}

using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        //Console.SetIn(File.OpenText("../../input.txt"));

        string str = "";
        while (!string.IsNullOrEmpty((str = Console.ReadLine())))
        {
            int res = 0;
            for (int i = 0; i < str.Length; ++i)
            {
                for (int j = i + 1; j < str.Length; ++j)
                {
                    int k = 0;
                    while (i + k < str.Length && j + k < str.Length && str[i + k] == str[j + k])
                    {
                        ++k;
                    }
                    res = Math.Max(res, k);
                }
            }
            Console.WriteLine(res);
        }
    }
}

/*******************************************************************************
* Author: Nirushuu
*******************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.IO;
using System.Globalization;
using System.Numerics;

/*******************************************************************************
* IO from Kattio.cs from open.kattis.com/help/csharp                          */
public class NoMoreTokensException : Exception
{
}

public class Tokenizer
{
    string[] tokens = new string[0];
    private int pos;
    StreamReader reader;

    public Tokenizer(Stream inStream)
    {
        var bs = new BufferedStream(inStream);
        reader = new StreamReader(bs);
    }

    public Tokenizer() : this(Console.OpenStandardInput())
    {
        // Nothing more to do
    }

    private string PeekNext()
    {
        if (pos < 0)
            // pos < 0 indicates that there are no more tokens
            return null;
        if (pos < tokens.Length)
        {
            if (tokens[pos].Length == 0)
            {
                ++pos;
                return PeekNext();
            }
            return tokens[pos];
        }
        string line = reader.ReadLine();
        if (line == null)
        {
            // There is no more data to read
            pos = -1;
            return null;
        }
        // Split the line that was read on white space characters
        tokens = line.Split(null);
        pos = 0;
        return PeekNext();
    }

    public bool HasNext()
    {
        return (PeekNext() != null);
    }

    public string Next()
    {
        string next = PeekNext();
        if (next == null)
            throw new NoMoreTokensException();
        ++pos;
        return next;
    }
}

public class Scanner : Tokenizer
{

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public float NextFloat()
    {
        return float.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }
}

public class BufferedStdoutWriter : StreamWriter
{
    public BufferedStdoutWriter() : base(new BufferedStream(Console.OpenStandardOutput()))
    {
    }
}
/******************************************************************************/

/*******************************************************************************
* DisjointSet datastructure                                                   */
public struct DisjointSet {
    public int[] parent;
    public int[] rank;
    public DisjointSet(int n) {
        parent = new int[n];
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
        rank = new int[n];
    }

    public int Find(int i) {
        int idx = i;
        var compress = new List<int>();
        while (idx != parent[idx]) {
            compress.Add(idx);
            idx = parent[idx];
        }

        foreach (var e in compress) {   // path compress
            parent[e] = idx;
        }
        return idx;
    }

    public void Union(int a, int b) {
        int aPar = this.Find(a);
        int bPar = this.Find(b);

        if (rank[aPar] > rank[bPar]) {  // by rank
            parent[bPar] = aPar;
        } else {
            parent[aPar] = bPar;
        }
        if (rank[aPar] == rank[bPar]) {
            ++rank[bPar];
        }
    }
}

class MaxHeap {
    List<int> data;

    public MaxHeap() {
        data = new List<int>();
    }

    public void Add(int a) {
        data.Add(a);
        int idx = data.Count - 1;
        int parent = (int) Math.Floor((double) (idx - 1) / 2);
        while (idx != 0 && (data[idx] > data[parent])) {
            int tmp = data[parent];
            data[parent] = data[idx];
            data[idx] = tmp;

            idx = parent;
            parent = (int) Math.Floor((double) (idx - 1) / 2);
        }
    }

    public int Pop() {
        int res = data[0];
        data[0] = data[data.Count - 1];
        data.RemoveAt(data.Count - 1);

        int idx = 0;
        while (true) {
            int child1 = (2 * idx) + 1;
            int child2 = (2 * idx) + 2;

            if (child1 >= data.Count) { // no children
                break;
            } else if (child2 >= data.Count) {  // one child
                if (data[idx] < data[child1]) {
                    int tmp = data[idx];
                    data[idx] = data[child1];
                    data[child1] = tmp;
                }
                break;
            } else {    // two children
                int maxChild = data[child1] > data[child2] ? child1 : child2;
                if (data[idx] < data[maxChild]) {
                    int tmp = data[idx];
                    data[idx] = data[maxChild];
                    data[maxChild] = tmp;
                    idx = maxChild;
                    continue;
                } else {    // no swap
                    break;
                }
            }
        }

        return res;
    }

}

class Dequeue {
    public Dictionary<int, int> data = new Dictionary<int, int>();
    int firstIdx;
    public int Count;
    public Dequeue() {
        data = new Dictionary<int, int>();
        firstIdx = 1;
        Count = 0;
    }

    public void PushFront(int a) {
        data[firstIdx - 1] = a;
        ++Count;
        --firstIdx;
    }

    public void PushBack(int a) {
        data[firstIdx + Count] = a;
        ++Count;
    }

    public int PopFront() {
        --Count;
        ++firstIdx;
        return data[firstIdx - 1];
    }

    public int PopBack() {
        --Count;
        return data[firstIdx + Count];
    }

    public int Get(int n) {
        return data[firstIdx + n];
    }
}
/******************************************************************************/

class MainClass {

    // Debug functions
    static void debug<T>(IEnumerable<T> a, string s = "") {
        Console.WriteLine($"name: {s}");
        int i = 0;
        foreach (var e in a) {
            Console.WriteLine($"value {i}: {e}");
            ++i;
        }
    }
    static void dbg<T>(T a, string s = "") {
        Console.WriteLine($"name: {s} value: {a}");
    }
    ////////////////////

    static int gcd(int a, int b) {
        while (b != 0) {
            int t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    static bool between(int a, int b, int c) {
        return (a >= b && a <= c);
    }

    static int findIn(string s, string a) {
        for (int i = 0; i < s.Length - (a.Length - 1); ++i) {
            bool found = true;
            for (int j = 0; j < a.Length; ++j) {
                if (s[i + j] != a[j]) {
                    found = false;
                    break;
                }
            }

            if (found) {
                return i;
            }
        }

        return -1;
    }

    static double dist(double a, double b, double c, double d) {
        return Math.Sqrt(Math.Pow((a - c), 2) + Math.Pow((b - d), 2));
    }

    public static void Main() {

        var sc = new Scanner();
        var wr = new BufferedStdoutWriter();
        var dot = new NumberFormatInfo();
        dot.NumberDecimalSeparator = ".";

        var s = new List<char>(sc.Next());
        for (int i = s.Count - 1; i > 0; --i) {
            for (int j = 0; j + i - 1 < s.Count; ++j) {
                for (int k = j + 1; k + i - 1 < s.Count; ++k) {

                    bool ok = true;
                    for (int l = 0; l < i; ++l) {
                        if (s[k + l] != s[j + l]) {
                            ok = false;
                            break;
                        }
                    }
                    if (ok) {
                        wr.WriteLine(i);
                        wr.Flush();
                        return;
                    }
                }
            }
        }

        wr.WriteLine(0);

        wr.Flush();

    }
}

using System;

namespace Task_23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < input.Length - 1; i++)
            {
                for (int count = 1; count < input.Length; count++)
                {
                    for (int j = i + 1; j <= input.Length - count; j++)
                    {
                        string A = input.Substring(i, count);
                        string B = input.Substring(j, count );
                        if (A.Equals(B))
                        {
                            ans = count > ans ? count : ans;
                        }

                    }
                }

            }

            Console.WriteLine(ans);
            //Console.ReadKey();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader tr = Console.In;
            string str = tr.ReadLine();

            int maxlen = 0;

            for (int i = 1; i < str.Length; i++)
            {
                Dictionary<string, bool> ret = new Dictionary<string, bool>();
                for (int j = 0; j < str.Length; j++)
                {
                    if (i + j > str.Length) break;
                    string sub = string.Empty;
                    for (int k = j; k < j+i; k++)
                    {
                        sub += str[k];
                    }
                    if (ret.ContainsKey(sub))
                    {
                        maxlen = Math.Max(i, maxlen);
                        break;
                    }
                    else
                    {
                        ret[sub] = true;
                    }
                }
            }

            Console.WriteLine(maxlen);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    void solve()
    {
        string s = nextString();
        Dictionary<string, int> d = new Dictionary<string, int>();
        for (int i = 0; i < s.Length; i++)
            for (int l = 1; l + i <= s.Length; l++)
                if (!d.ContainsKey(s.Substring(i, l)))
                {
                    d[s.Substring(i,l)]=1;
                }
                else
                    d[s.Substring(i, l)]++;
        int ret=0;
        foreach(KeyValuePair<string,int>x in d)
            if(x.Value>1)
            ret=Math.Max(ret,x.Key.Length);
        println(ret);

    }

    ////////////

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        Console.WriteLine(Doublenum);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
class Program
{
    static int max = -1;
    static void Main()
    {
        string st = Console.ReadLine();
        substrs(st);
        Console.WriteLine(max);
        Console.Read();
    }

    static void pref(string s)
    {
        int n = s.Length;
        int[] pi = new int[n];
        pi[0] = 0;
        for (int i = 1; i < n; i++)
        {
            int j = pi[i - 1];
            while (j > 0 && s[i] != s[j])
                j = pi[j - 1];
            if (s[i] == s[j]) ++j;
            pi[i] = j;
        }
        max = Math.Max(max, pi[s.Length - 1]);
    }

    static void substrs(string s)
    {
        int l = s.Length;
        for (int i = 0; i < l; i++)
        {
            for (int j = i; j < l; j++)
            {
                pref(s.Substring(i, j - i + 1));
            }
        }
    }
}

using System.Collections.Generic;
using System;
class some
{
	public static void Main()
	{
		string s=Console.ReadLine();
		List<string> ll=new List<string>();
		for(int i=0;i<s.Length;i++)
		{
			for(int j=1;j<s.Length-i;j++)
			{
				ll.Add(s.Substring(i,j));
			}
		}
		int max=0;
		for(int i=0;i<ll.Count;i++)
		{
			int ind=s.IndexOf(ll[i]);
			if(ind==s.Length-1)continue;
			if(s.IndexOf(ll[i],ind+1)>-1)
			{
				max=Math.Max(max,ll[i].Length);
			}
		}
		Console.WriteLine(max);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;

namespace CodeForces_Runners
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();

            int n = s.Length;

            if (n == 1)
            {
                Console.WriteLine("0");
                return;
            }

            for (int j = n - 2; j >= 0; j-- )
            {
                ArrayList subs = new ArrayList();

                int temp = j;
                for (int i = 0; i < n - j; i++)
                {
                    string sub = s.Substring(i, temp - i + 1);
                    if (subs.Contains(sub))
                    {
                        Console.WriteLine(temp - i + 1);
                        return;
                    }
                    else
                        subs.Add(sub);

                    temp++;
                }

            }

            Console.WriteLine("0");
        }

    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            string s = RL();

            for (int i = s.Length - 1; i > 0; i--) {
                for (int j = 0; j < s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    int tmp = KMP(s, subs);
                    if (tmp >= 2) {
                        println(subs.Length);
                        //close(file);
                        return;
                    }
                }
            }

            println(0);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count = 0;
            bool flag;

            for (int i = 0; i < mainStr.Length-subs.Length+1; i++) {
                flag = true;
                for (int j = 0, k=i; j < subs.Length; j++, k++) {
                    if (subs[j] != mainStr[k]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) count++;
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.IO;
using System.Text;

namespace You_re_Given_a_String
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string s = reader.ReadLine();

            int max = 0;

            for (int i = 0; i < s.Length; i++)
            {
                for (int j = i + max; j < s.Length; j++)
                {
                    for (int k = i + 1; k < s.Length; k++)
                    {
                        bool ok = true;
                        for (int l = i; l <= j; l++)
                        {
                            int index = k + l - i;
                            if (index == s.Length)
                            {
                                ok = false;
                                break;
                            }
                            if (s[l] != s[index])
                            {
                                ok = false;
                                break;
                            }
                        }
                        if (ok)
                        {
                            if (j - i + 1 > max)
                                max = j - i + 1;
                        }
                    }
                }
            }

            writer.WriteLine(max);
            writer.Flush();
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var str = Console.ReadLine();
            int n = str.Length;
            int max = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    var length = j - i + 1;
                    for (int i2 = 0; i2 < n; i2++)
                    {

                        var last = i2 + length - 1;

                        if (last >= n || i2 == i)
                        {
                            break;
                        }

                        var eq = true;

                        for (int c = 0; c < length; c++)
                        {
                            if (str[i + c] != str[i2 + c])
                            {
                                eq = false;
                            }
                        }

                        if (eq)
                        {
                            if (length > max)
                            {
                                max = length;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Numerics;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        string s = ReadToken();
        int n = s.Length;
        for (int len = n - 1; len > 0; len--)
            for (int i = 0; i + len <= n; i++)
            {
                string t = s.Substring(i, len);
                int c = 0;
                for (int j = 0; j + len <= n; j++)
                    if (s.Substring(j, len) == t)
                        c++;
                if (c > 1)
                {
                    Write(len);
                    return;
                }
            }
        Write(0);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces_Beta_Round_23
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var max = 0;
            for (var i = 0; i < str.Length - 1; i++)
            {
                if (i >= str.Length - max)
                {
                    break;
                }
                for (var j = i + 1; j < str.Length; j++)
                {
                    if (j >= str.Length - max)
                        break;

                    if (str[i] == str[j])
                    {
                        var indx = 1;
                        while (j + indx < str.Length && str[i + indx] == str[j + indx])
                            indx++;

                        if (indx > max)
                            max = indx;
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_23_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string sub;
            string comp_str;
            int leng = 1;
            int max = 0;

            for (int i = 0; i < s.Length; i++)
            {
                leng = 1;
                List<int> lst = new List<int>();
                for (int j = i+1; j < s.Length; j++)
                    lst.Add(j);
                while (true)
                {
                    List<int> lst2 = new List<int>();
                    sub = s.Substring(i, leng);
                    foreach (var k in lst)
                    {
                        if (k + leng > s.Length) break;
                        comp_str = s.Substring(k, leng);
                        if (comp_str == sub)
                            lst2.Add(k);

                    }
                    if (lst2.Count == 0) break;
                    lst = lst2;
                    if (leng > max) max = leng;
                    leng++;
                }

                if (s.Length - i < max) break;
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_23_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string sub;
            string comp_str;
            int leng = 1;
            int max = 0;

            for (int i = 0; i < s.Length; i++)
            {
                leng = 1;
                List<int> lst = new List<int>();
                for (int j = i+1; j < s.Length; j++)
                    lst.Add(j);
                while (true)
                {
                    List<int> lst2 = new List<int>();
                    foreach (var k in lst)
                    {
                        if (k + leng > s.Length) break;
                        if (s[i+leng-1] == s[k+leng-1])
                            lst2.Add(k);

                    }
                    if (lst2.Count == 0) break;
                    lst = lst2;
                    if (leng > max) max = leng;
                    leng++;
                }

                if (s.Length - i < max) break;
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class CF_23A
{
    static void Main()
    {
        string str = Console.ReadLine();
        if (str.Length < 2)
        {
            Console.WriteLine(0);
            return;
        }

        int len;
        for (len = str.Length; len >= 0; len--)
        {
            for (int i = 0; i + len <= str.Length; i++)
            {
                string sub = str.Substring(i, len);
                int cnt = 0;
                for (int p = str.IndexOf(sub, 0) ; p < str.Length && p != -1; p = str.IndexOf(sub, ++p))
                {
                    cnt++;
                    if (cnt >= 2)
                    {
                        Console.WriteLine(len);
                        return;
                    }
                }
            }
        }
    }
}

using System;

namespace Task23Astring
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < input.Length - 1; i++)
            {
                for (int count = 1; count < input.Length; count++)
                {
                    for (int inner = i + 1; inner <= input.Length - count; inner++)
                    {
                        if (input.Substring(i, count) == input.Substring(inner, count))
                            ans = count > ans ? count : ans;
                    }
                }
            }
            Console.WriteLine(ans);
           // Console.ReadKey();

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CF23
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int maxLenth = 0;
            for (int i = 0; i < str.Length; i++)
            {
                for (int j = i + 1; j < str.Length; j++)
                {
                    if (str[i] == str[j])
                    {
                        int curLength = 0;
                        int k = i;
                        int t = j;
                        while (t<str.Length && str[k] == str[t])
                        {
                            t++;
                            k++;
                            curLength++;
                        }
                        if (curLength > maxLenth)
                        {
                            maxLenth = curLength;
                        }
                    }
                }
            }
            Console.Write(maxLenth);
            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                int mlen = 0;
                for (int j = 0; j < line.Length; j++)
                {
                    int len = 0;
                    for (int i = j+1; i < line.Length; i++)
                    {
                        int lmlen = comp(line, j, i);
                        if (lmlen > len) len = lmlen;
                    }
                    if (len > mlen) mlen = len;
                }
                Console.WriteLine(mlen);
            }
        }
        static int comp(string str, int i, int j)
        {
            int len = 0;
            while (i < str.Length && j < str.Length)
            {
                if (str[i] != str[j]) return len;
                i++; j++; len++;
            }
            return len;
        }
    }
}

using System;
using System.Text;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

}

class Solution
{
    Scanner cin;

    public static void Main()
    {
        new Solution().calc();
    }

    void calc()
    {
        cin = new Scanner();
        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[i + k] != s[j + k]) break;
                    ret = Math.Max(k + 1, ret);
                }
            }
        }
        Console.WriteLine(ret);
    }
}

using System;
// you can also use other imports, for example:
using System.Collections.Generic;
using System.Linq;

// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");

//mcs HelloWorld.cs
//mono HelloWorld.exe
public class HelloWorld {

	public static void Main(string[] args)
	{
		var line  = Console.ReadLine();
		solve(line);
		//tests();
	}

	public static void tests()
	{
		solve("abcd");
		solve("ababa");
		solve("zzz");
	}

	public static void solve(string line)
	{
		var dict = new Dictionary<string, int>();

		for (var i = 0; i < line.Length; i++)
		{
			var st = line[i].ToString();
			if (dict.ContainsKey(st))
				dict[st] += 1;
			else
				dict[st] = 0;

			for (var j  = i+1; j < line.Length; j++)
			{
				st += line[j];
				if (dict.ContainsKey(st))
				{
					dict[st] += 1;

				}
				else
				{
					dict[st] = 0;
				}
			}
		}

		var max = 0;
		foreach( var d in dict)
		{
			//Console.WriteLine(d.Key + " " + d.Value);
			if (d.Value > 0)
			{
				max = Math.Max(d.Key.Length, max);
			}
		}
		Console.WriteLine(max);

	}

}

using System;

namespace Iran
{
	class AmirGoharshady
	{
		public static void Main()
		{
			string s=Console.ReadLine();
			int ans=0;
			for(int i=0;i<s.Length;++i)
				for(int j=i+1;j<s.Length;++j)
					for(int len=0;j+len<=s.Length;++len)
					{
						if(s.Substring(i,len)==s.Substring(j,len))
						{
							if(s.Substring(i,len).Length>ans)
								ans=s.Substring(i,len).Length;
						}
					}
			Console.WriteLine(ans);
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForce
{
    class _23a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var z = 0;
            for (var i = line.Length - 1; i > 0; i--)
            {
                z++;
                for (var j = 0; j < z; j++)
                {
                    var str = line.Substring(j, i);
                    if (line.IndexOf(str, j + 1) >= 0)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }
            Console.WriteLine(0);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Task23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            //bool breaker=false;
            //for (int i = 0; i < str.Length-1; i++)
            //{
            //    for (int j = str.Length-1; j > 0; j--)
            //    {
            //        if (str.Substring(i+1,str.Length-1).Contains(str.Substring(i, j))) {
            //            Console.WriteLine(str.Substring(i, j).Length); breaker = true; break;}
            //    }
            //    if (breaker) break;
            //}
            //if (breaker == false) Console.WriteLine(0);

            int ans = 0, len = str.Length;
            for (int i = 0; i < len - 1; i++)
            {

                for (int count = 1; count < len; count++)
                {
                    for ( int j = i + 1;j+count <= len; j++)
                    {
                        string sub1=str.Substring(i,count);
                        string sub2 = str.Substring(j,count);
                        if (sub1.Equals(sub2) && sub1.Length > ans)
                            ans = sub1.Length;
                    }
                }
            }

            Console.WriteLine(ans);

        }

    }
}

using System;
using System.IO;

namespace q1
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader tr = Console.In;
            string buf = tr.ReadLine();
            int max = 0;
            string sub;
            for (int i = 0; i < buf.Length; i++)
            {
                for (int j = 1; i + j < buf.Length; j++)
                {
                    sub = buf.Substring(i, j);
                    if ((buf.Substring(i+1)).Contains(sub))
                    {
                        if (max < sub.Length)
                        {
                            max = sub.Length;
                        }
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}

using System;

public class Program
{
	public static void Main()
	{
		string str = Console.ReadLine();

		for(int i = 0; i < str.Length - 1; i++)
		{
			int maxLen = str.Length - i - 1;
			for(int j = 0; j < str.Length - maxLen; j++)
			{

				for(int k = j + 1; k < str.Length - maxLen + 1; k++)
				{
					bool match = true;

					for(int m = 0; m < maxLen; m++)
					{
						//Console.WriteLine("i: " + i + "; j: " + j + "; k: " + k + "; m: " + m);
						if(str[j + m] != str[k + m])
						{
							match = false;
							break;
						}
					}

					if(match)
					{
						Console.WriteLine(maxLen);
						return;
					}
				}
			}
		}

		Console.WriteLine(0);
	}
}

using System;
using System.Collections.Generic;

using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int max = 0;
            int d = 1; //как бэ сдвиг
            bool b = false;
            for (; d < s.Length; d++)
            {
                int cnt = 0;
                int cnt2 = 0;
                for (int i = d; i < s.Length; i++)
                {
                    if (s[i - d] == s[i])
                    {
                        if (b == false)
                        {
                            b = true;
                            cnt2 = Math.Max(cnt, cnt2);
                            cnt = 0;
                        }
                        cnt++;
                    }
                    else
                    {
                        b = false;
                    }
                }
                max = Math.Max(Math.Max(cnt, cnt2), max);
            }
            Console.WriteLine(max);
            Console.ReadLine();
        }
    }
}

using System;

namespace Task23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int ans = 0;
            for (int start = 0; start < input.Length - 2; start++)
            {

                for (int count = 2; count < input.Length; count++)
                {
                    for (int inner = start+1;inner <= input.Length - count ; inner++ )
                    {
                        if (
                            input.Substring(start, count).Equals(input.Substring(inner, count))
                            ) ans = count > ans ? count : ans;
                    }
                }

            }

            Console.WriteLine(ans);
           // Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace CodeForce
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            var listSample = new List<string>();

            var result = 0;

            for (int i = 1; i <= input.Length; i++)
            {
                for (int j = 0; j < input.Length; j++)
                {
                    if (j + i <= input.Length)
                        listSample.Add(input.Substring(j, i));
                    else break;
                }
            }

            var selectItem = (from res in listSample
                              where listSample.Count(y => res == y) > 1
                              && res.Length > 1
                              select res).Distinct();

            foreach (var item in selectItem)
            {
                if (item.ToString().Length > result)
                {
                    result = item.ToString().Length;
                }
            }

            Console.WriteLine(result);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int n = line.Length - 1;
            Dictionary<string, int> d = new Dictionary<string, int>();

            while (n > 0)
            {
                List<String> list = Split(line, n);

                foreach (String s in list)
                {
                    int o = Occurs(line, s);
                    if (o >= 2)
                    {
                        d.Add(s, o);
                    }
                }

                n--;
            }

            if (d.Count > 0)
            {
                int max = d.Values.Max();

                foreach (String s in d.Keys)
                {
                    if (d[s] == max)
                    {
                        Console.WriteLine(s.Length);
                        break;
                    }
                }
            }
            else
                Console.WriteLine("0");

        }

        static List<String> Split(string input,int n)
        {
            List<String> list = new List<string>();
            int counter = 0;

            while (counter+n <= input.Length)
            {
                if (!list.Contains(input.Substring(counter, n)))
                {
                    list.Add(input.Substring(counter, n));

                }
                counter++;

            }

            return list;
        }

        static int Occurs(string input,string sub)
        {
            int counter = 0;
            int count = 0;
            while (counter + sub.Length <= input.Length)
            {
                if (input.Substring(counter, sub.Length) == sub)
                {
                    count++;
                }
                counter++;
            }
            return count;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _23A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int n = line.Length - 1;
            Dictionary<string, int> d = new Dictionary<string, int>();

            while (n > 1)
            {
                List<String> list = Split(line, n);

                foreach (String s in list)
                {
                    int o = Occurs(line, s);
                    if (o >= 2)
                    {
                        d.Add(s, o);
                    }
                }

                n--;
            }

            if (d.Count > 0)
            {
                int max = d.Values.Max();

                foreach (String s in d.Keys)
                {
                    if (d[s] == max)
                    {
                        Console.WriteLine(s.Length);
                        break;
                    }
                }
            }
            else
                Console.WriteLine("0");

        }

        static List<String> Split(string input,int n)
        {
            List<String> list = new List<string>();
            int counter = 0;

            while (counter+n <= input.Length)
            {
                if (!list.Contains(input.Substring(counter, n)))
                {
                    list.Add(input.Substring(counter, n));

                }
                counter++;

            }

            return list;
        }

        static int Occurs(string input,string sub)
        {
            int counter = 0;
            int count = 0;
            while (counter + sub.Length <= input.Length)
            {
                if (input.Substring(counter, sub.Length) == sub)
                {
                    count++;
                }
                counter++;
            }
            return count;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Numerics;
using System.Globalization;

namespace JalalHani
{
    class Vertex
    {
        public List<int> relations = new List<int>();
        public List<int> weights = new List<int>();
        public Vertex(int r , int w)
        {
            this.relations.Add(r);
            this.weights.Add(w);
        }
        public void AddInfo (int r, int w)
        {
            this.relations.Add(r);
            this.weights.Add(w);
        }
        ////Dijkstra
        //int[] data = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        //int n = data[0], m = data[1];
        //Dictionary<int, Vertex> Edges = new Dictionary<int, Vertex>();
        //for (int i = 0; i < m; i++)
        //{
        //    data = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        //    int k = data[0], r = data[1], w = data[2];
        //    if (Edges.Keys.Contains(k))
        //    {
        //        Edges[k].AddInfo(r,w);
        //    }
        //    else
        //    {
        //        Edges.Add(k, new Vertex(r, w));
        //    }
        //}

        //foreach (var edge in Edges)
        //{

        //}
    }

    class Program
    {

        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long o = 0;
            List<string> rep = new List<string>();

            for (int length = 2; length < s.Length; length++)
            {
                for (int j = 0; j <= s.Length-length; j++)
                {
                    string subS = s.Substring(j, length);
                    bool u = SearchInSubstring(s,subS,j,length);
                    if (u)
                    {
                        rep.Add(subS);
                    }
                }
            }
            if (rep.Count > 0)
            o = rep.Select(x => x.Length).Max();
            Console.WriteLine(o);
        }

        static bool SearchInSubstring (string source, string cut,int indexStart, int EndString) {
            bool found = false;

            found = source.Remove(indexStart,1).Contains(cut);

            return found;
        }

        static int Test(int v , int m)
        {
            int p1 = 0;
            int dif = (int)Math.Ceiling((double)m / v);
            int diff = v * dif;
            p1 = (diff - m);
            p1 += dif == 2 ? 1 : dif;

            return p1;
        }

        static void MulticasesQuestion()
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
                SolveTestCase();
        }
        static void SolveTestCase()
        {

        }
        static int GCD(int a1, int a2)
        {
            int mx = Math.Max(a1, a2);
            int mn = Math.Min(a1, a2);

            if (mx % mn == 0)
            {
                return mn;
            }
            else GCD(mn, mx % mn);
            return 1;
        }

        static BigInteger Pow(int b, int a)
        {
            BigInteger x = 1;

            for (int i = 0; i < a; i++)
            {
                x *= b;
            }

            return x;
        }
        static void LeastCostBracketSequence()
        {
            var input = Console.ReadLine().ToCharArray();
            var isSolutionExists = true;
            long totalCost = 0;
            var balance = 0;

            var sortedVariants = new List<Variant>();
            var comparer = new ByCostSwitch();

            for (var i = 0; i < input.Length; i++)
            {
                if (input[i] == '(')
                {
                    balance++;
                }
                else if (input[i] == ')')
                {
                    balance--;
                }
                else
                {
                    var costValue = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
                    var variant = new Variant()
                    {
                        CostSwitch = costValue[0] - costValue[1],
                        Position = i
                    };

                    var index = sortedVariants.BinarySearch(variant, comparer);
                    if (index < 0)
                    {
                        index = ~index;
                    }

                    sortedVariants.Insert(index, variant);

                    totalCost += costValue[1];
                    balance--;
                }

                if (balance < 0)
                {
                    if (sortedVariants.Count == 0)
                    {
                        isSolutionExists = false;
                        break;
                    }

                    var sortedVariant = sortedVariants[0];

                    input[sortedVariant.Position] = '(';
                    totalCost += sortedVariant.CostSwitch;
                    balance += 2;
                    sortedVariants.RemoveAt(0);
                }
            }

            isSolutionExists = (balance == 0);

            if (isSolutionExists)
            {
                Console.WriteLine(totalCost);
                for (var i = 0; i < input.Length; i++)
                {
                    if (input[i] == '?')
                    {
                        Console.Write(')');
                    }
                    else
                    {
                        Console.Write(input[i]);
                    }
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
        class Commands
        {
            public static int[] NextIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).ToArray();
                }
            }
            public static List<int> NextIntList
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).ToList();
                }
            }
            public static int[] NextSortedIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
                }
            }
            public static int[] NextDescSortedIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
                }
            }
            public static long[] NextLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).ToArray();
                }
            }
            public static List<long> NextLongList
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).ToList();
                }
            }
            public static long[] NextSortedLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
                }
            }
            public static long[] NextDescSortedLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
                }
            }
            public static int NextInt
            {
                get
                {
                    return int.Parse(Console.ReadLine());
                }
            }

            public static string NextString
            {
                get { return Console.ReadLine(); }
            }
        }

        private class Variant
        {
            public int CostSwitch;
            public int Position;
        }

        private class ByCostSwitch : IComparer<Variant>
        {
            #region IComparer implementation
            public int Compare(Variant x, Variant y)
            {
                return x.CostSwitch.CompareTo(y.CostSwitch);
            }
            #endregion
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Numerics;
using System.Globalization;

namespace JalalHani
{
    class Vertex
    {
        public List<int> relations = new List<int>();
        public List<int> weights = new List<int>();
        public Vertex(int r , int w)
        {
            this.relations.Add(r);
            this.weights.Add(w);
        }
        public void AddInfo (int r, int w)
        {
            this.relations.Add(r);
            this.weights.Add(w);
        }
        ////Dijkstra
        //int[] data = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        //int n = data[0], m = data[1];
        //Dictionary<int, Vertex> Edges = new Dictionary<int, Vertex>();
        //for (int i = 0; i < m; i++)
        //{
        //    data = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        //    int k = data[0], r = data[1], w = data[2];
        //    if (Edges.Keys.Contains(k))
        //    {
        //        Edges[k].AddInfo(r,w);
        //    }
        //    else
        //    {
        //        Edges.Add(k, new Vertex(r, w));
        //    }
        //}

        //foreach (var edge in Edges)
        //{

        //}
    }

    class Program
    {

        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long o = 0;
            List<string> rep = new List<string>();

            for (int length = 1; length < s.Length; length++)
            {
                for (int j = 0; j <= s.Length-length; j++)
                {
                    string subS = s.Substring(j, length);
                    bool u = SearchInSubstring(s,subS,j,length);
                    if (u)
                    {
                        rep.Add(subS);
                    }
                }
            }
            if (rep.Count > 0)
            o = rep.Select(x => x.Length).Max();
            Console.WriteLine(o);
        }

        static bool SearchInSubstring (string source, string cut,int indexStart, int EndString) {
            bool found = false;

            found = source.Remove(indexStart,1).Contains(cut);

            return found;
        }

        static int Test(int v , int m)
        {
            int p1 = 0;
            int dif = (int)Math.Ceiling((double)m / v);
            int diff = v * dif;
            p1 = (diff - m);
            p1 += dif == 2 ? 1 : dif;

            return p1;
        }

        static void MulticasesQuestion()
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
                SolveTestCase();
        }
        static void SolveTestCase()
        {

        }
        static int GCD(int a1, int a2)
        {
            int mx = Math.Max(a1, a2);
            int mn = Math.Min(a1, a2);

            if (mx % mn == 0)
            {
                return mn;
            }
            else GCD(mn, mx % mn);
            return 1;
        }

        static BigInteger Pow(int b, int a)
        {
            BigInteger x = 1;

            for (int i = 0; i < a; i++)
            {
                x *= b;
            }

            return x;
        }
        static void LeastCostBracketSequence()
        {
            var input = Console.ReadLine().ToCharArray();
            var isSolutionExists = true;
            long totalCost = 0;
            var balance = 0;

            var sortedVariants = new List<Variant>();
            var comparer = new ByCostSwitch();

            for (var i = 0; i < input.Length; i++)
            {
                if (input[i] == '(')
                {
                    balance++;
                }
                else if (input[i] == ')')
                {
                    balance--;
                }
                else
                {
                    var costValue = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
                    var variant = new Variant()
                    {
                        CostSwitch = costValue[0] - costValue[1],
                        Position = i
                    };

                    var index = sortedVariants.BinarySearch(variant, comparer);
                    if (index < 0)
                    {
                        index = ~index;
                    }

                    sortedVariants.Insert(index, variant);

                    totalCost += costValue[1];
                    balance--;
                }

                if (balance < 0)
                {
                    if (sortedVariants.Count == 0)
                    {
                        isSolutionExists = false;
                        break;
                    }

                    var sortedVariant = sortedVariants[0];

                    input[sortedVariant.Position] = '(';
                    totalCost += sortedVariant.CostSwitch;
                    balance += 2;
                    sortedVariants.RemoveAt(0);
                }
            }

            isSolutionExists = (balance == 0);

            if (isSolutionExists)
            {
                Console.WriteLine(totalCost);
                for (var i = 0; i < input.Length; i++)
                {
                    if (input[i] == '?')
                    {
                        Console.Write(')');
                    }
                    else
                    {
                        Console.Write(input[i]);
                    }
                }
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
        class Commands
        {
            public static int[] NextIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).ToArray();
                }
            }
            public static List<int> NextIntList
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).ToList();
                }
            }
            public static int[] NextSortedIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
                }
            }
            public static int[] NextDescSortedIntArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
                }
            }
            public static long[] NextLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).ToArray();
                }
            }
            public static List<long> NextLongList
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).ToList();
                }
            }
            public static long[] NextSortedLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
                }
            }
            public static long[] NextDescSortedLongArray
            {
                get
                {
                    return Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
                }
            }
            public static int NextInt
            {
                get
                {
                    return int.Parse(Console.ReadLine());
                }
            }

            public static string NextString
            {
                get { return Console.ReadLine(); }
            }
        }

        private class Variant
        {
            public int CostSwitch;
            public int Position;
        }

        private class ByCostSwitch : IComparer<Variant>
        {
            #region IComparer implementation
            public int Compare(Variant x, Variant y)
            {
                return x.CostSwitch.CompareTo(y.CostSwitch);
            }
            #endregion
        }
    }
}

using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        //Console.SetIn(File.OpenText("../../input.txt"));

        string str = "";
        while (!string.IsNullOrEmpty((str = Console.ReadLine())))
        {
            int res = int.MinValue;
            for (int i = 0; i < str.Length; ++i)
            {
                for (int j = i + 1; j < str.Length; ++j)
                {
                    int k = 0;
                    while (i + k < str.Length && j + k < str.Length && str[i + k] == str[j + k])
                    {
                        ++k;
                    }
                    res = Math.Max(res, k);
                }
            }
            Console.WriteLine(res);
        }
    }
}

/*******************************************************************************
* Author: Nirushuu
*******************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.IO;
using System.Globalization;
using System.Numerics;

/*******************************************************************************
* IO from Kattio.cs from open.kattis.com/help/csharp                          */
public class NoMoreTokensException : Exception
{
}

public class Tokenizer
{
    string[] tokens = new string[0];
    private int pos;
    StreamReader reader;

    public Tokenizer(Stream inStream)
    {
        var bs = new BufferedStream(inStream);
        reader = new StreamReader(bs);
    }

    public Tokenizer() : this(Console.OpenStandardInput())
    {
        // Nothing more to do
    }

    private string PeekNext()
    {
        if (pos < 0)
            // pos < 0 indicates that there are no more tokens
            return null;
        if (pos < tokens.Length)
        {
            if (tokens[pos].Length == 0)
            {
                ++pos;
                return PeekNext();
            }
            return tokens[pos];
        }
        string line = reader.ReadLine();
        if (line == null)
        {
            // There is no more data to read
            pos = -1;
            return null;
        }
        // Split the line that was read on white space characters
        tokens = line.Split(null);
        pos = 0;
        return PeekNext();
    }

    public bool HasNext()
    {
        return (PeekNext() != null);
    }

    public string Next()
    {
        string next = PeekNext();
        if (next == null)
            throw new NoMoreTokensException();
        ++pos;
        return next;
    }
}

public class Scanner : Tokenizer
{

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public float NextFloat()
    {
        return float.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }
}

public class BufferedStdoutWriter : StreamWriter
{
    public BufferedStdoutWriter() : base(new BufferedStream(Console.OpenStandardOutput()))
    {
    }
}
/******************************************************************************/

/*******************************************************************************
* DisjointSet datastructure                                                   */
public struct DisjointSet {
    public int[] parent;
    public int[] rank;
    public DisjointSet(int n) {
        parent = new int[n];
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
        rank = new int[n];
    }

    public int Find(int i) {
        int idx = i;
        var compress = new List<int>();
        while (idx != parent[idx]) {
            compress.Add(idx);
            idx = parent[idx];
        }

        foreach (var e in compress) {   // path compress
            parent[e] = idx;
        }
        return idx;
    }

    public void Union(int a, int b) {
        int aPar = this.Find(a);
        int bPar = this.Find(b);

        if (rank[aPar] > rank[bPar]) {  // by rank
            parent[bPar] = aPar;
        } else {
            parent[aPar] = bPar;
        }
        if (rank[aPar] == rank[bPar]) {
            ++rank[bPar];
        }
    }
}

class MaxHeap {
    List<int> data;

    public MaxHeap() {
        data = new List<int>();
    }

    public void Add(int a) {
        data.Add(a);
        int idx = data.Count - 1;
        int parent = (int) Math.Floor((double) (idx - 1) / 2);
        while (idx != 0 && (data[idx] > data[parent])) {
            int tmp = data[parent];
            data[parent] = data[idx];
            data[idx] = tmp;

            idx = parent;
            parent = (int) Math.Floor((double) (idx - 1) / 2);
        }
    }

    public int Pop() {
        int res = data[0];
        data[0] = data[data.Count - 1];
        data.RemoveAt(data.Count - 1);

        int idx = 0;
        while (true) {
            int child1 = (2 * idx) + 1;
            int child2 = (2 * idx) + 2;

            if (child1 >= data.Count) { // no children
                break;
            } else if (child2 >= data.Count) {  // one child
                if (data[idx] < data[child1]) {
                    int tmp = data[idx];
                    data[idx] = data[child1];
                    data[child1] = tmp;
                }
                break;
            } else {    // two children
                int maxChild = data[child1] > data[child2] ? child1 : child2;
                if (data[idx] < data[maxChild]) {
                    int tmp = data[idx];
                    data[idx] = data[maxChild];
                    data[maxChild] = tmp;
                    idx = maxChild;
                    continue;
                } else {    // no swap
                    break;
                }
            }
        }

        return res;
    }

}

class Dequeue {
    public Dictionary<int, int> data = new Dictionary<int, int>();
    int firstIdx;
    public int Count;
    public Dequeue() {
        data = new Dictionary<int, int>();
        firstIdx = 1;
        Count = 0;
    }

    public void PushFront(int a) {
        data[firstIdx - 1] = a;
        ++Count;
        --firstIdx;
    }

    public void PushBack(int a) {
        data[firstIdx + Count] = a;
        ++Count;
    }

    public int PopFront() {
        --Count;
        ++firstIdx;
        return data[firstIdx - 1];
    }

    public int PopBack() {
        --Count;
        return data[firstIdx + Count];
    }

    public int Get(int n) {
        return data[firstIdx + n];
    }
}
/******************************************************************************/

class MainClass {

    // Debug functions
    static void debug<T>(IEnumerable<T> a, string s = "") {
        Console.WriteLine($"name: {s}");
        int i = 0;
        foreach (var e in a) {
            Console.WriteLine($"value {i}: {e}");
            ++i;
        }
    }
    static void dbg<T>(T a, string s = "") {
        Console.WriteLine($"name: {s} value: {a}");
    }
    ////////////////////

    static int gcd(int a, int b) {
        while (b != 0) {
            int t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    static bool between(int a, int b, int c) {
        return (a >= b && a <= c);
    }

    static int findIn(string s, string a) {
        for (int i = 0; i < s.Length - (a.Length - 1); ++i) {
            bool found = true;
            for (int j = 0; j < a.Length; ++j) {
                if (s[i + j] != a[j]) {
                    found = false;
                    break;
                }
            }

            if (found) {
                return i;
            }
        }

        return -1;
    }

    static double dist(double a, double b, double c, double d) {
        return Math.Sqrt(Math.Pow((a - c), 2) + Math.Pow((b - d), 2));
    }

    public static void Main() {

        var sc = new Scanner();
        var wr = new BufferedStdoutWriter();
        var dot = new NumberFormatInfo();
        dot.NumberDecimalSeparator = ".";

        var s = new List<char>(sc.Next());
        for (int i = s.Count - 1; i > 0; --i) {
            for (int j = 1; j + i - 1 < s.Count; ++j) {
                bool ok = true;
                for (int l = 0; l < i; ++l) {
                    if (s[l] != s[j + l]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    wr.WriteLine(i);
                    wr.Flush();
                    return;
                }
            }
        }

        wr.WriteLine(0);

        wr.Flush();

    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader tr = Console.In;
            string str = tr.ReadLine();

            int maxlen = 0;

            for (int i = 2; i < str.Length; i++)
            {

                Dictionary<string, bool> ret = new Dictionary<string, bool>();
                for (int j = 0; j < str.Length; j++)
                {
                    if (i + j > str.Length) break;
                    string sub = string.Empty;
                    for (int k = j; k < j+i; k++)
                    {
                        sub += str[k];
                    }
                    if (ret.ContainsKey(sub))
                    {
                        maxlen = Math.Max(i, maxlen);
                    }
                    else
                    {
                        ret[sub] = true;
                    }
                }
            }

            Console.WriteLine(maxlen);
        }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif
            string mainStr = RL();

            for (int i = mainStr.Length - 1; i > 0; i--) {
                for (int j = 0; j < mainStr.Length - i; j++) {
                    string subs = mainStr.Substring(j, i);
                    int tmp = KMP(mainStr, subs);
                    if (tmp >= 2) {
                        println(subs.Length);
                        //close(file);
                        return;
                    }
                }
            }

            println(0);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count = 0;
            int[] fail = new int[subs.Length+1];

            fail[1] = 0;
            for(int i=2; i<=subs.Length; i++){
                int tmp=fail[i-1];
                while(tmp>0 && subs[tmp]!=subs[i-1]) tmp=fail[tmp];
                fail[i] = tmp + 1;
            }

            int posInText=0, posInSubs = 0;
            while (posInText < mainStr.Length) {
                if (posInSubs == 0 || mainStr[posInText] == subs[posInSubs])
                {
                    posInSubs++;
                    posInText++;
                } else {
                    posInSubs = fail[posInSubs];
                }

                if (posInSubs == subs.Length) {
                    count++;
                    posInText = posInText - posInSubs + 1;
                    posInSubs = 0;
                }
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            int res = -1;
            string s = RL();

            for (int i = s.Length - 1; i > 0; i--) {
                for (int j = 0; j <= s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    res = Math.Max(res, KMP(s, subs));
                }
            }

            if (res<2) println("0");
            else println(res);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count=0;
            int[] fail = new int[subs.Length + 1];

            fail[0]=0;
            for(int i=1; i<subs.Length; i++){
                int tmp=fail[i-1];
                while(tmp>0 && subs[tmp]!=subs[i-1]) tmp=fail[tmp];
                fail[i]=tmp+1;
            }

            int posText=0, subText=0;
            while(posText<mainStr.Length){
               if (mainStr[posText]==subs[subText]){
                   posText++;
                   subText++;
               } else {
                   subText = fail[subText];
               }

               if(subText==subs.Length){
                    count++;
                    subText=0;
               }

               posText++;
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            string s = RL();

            for (int i = s.Length - 1; i > 1; i--) {
                for (int j = 0; j < s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    int tmp = KMP(s, subs);
                    if (tmp >= 2) {
                        println(subs.Length);
                        return;
                    }
                }
            }

            println(0);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count = 0;
            bool flag;

            for (int i = 0; i < mainStr.Length-subs.Length+1; i++) {
                flag = true;
                for (int j = 0, k=i; j < subs.Length; j++, k++) {
                    if (subs[j] != mainStr[k]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) count++;
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            int res = -1;
            string s = RL();

            for (int i = s.Length - 1; i > 0; i--) {
                for (int j = 0; j <= s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    res = Math.Max(res, KMP(s, subs));
                    //println(subs+"  res="+res);
                }
            }

            if (res<2) println("0");
            else println(res);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count=0;
            int[] fail = new int[subs.Length + 1];

            fail[1]=0;
            for(int i=2; i<=subs.Length; i++){
                int tmp=fail[i-1];
                while(tmp>0 && subs[tmp]!=subs[i-1]) tmp=fail[tmp];
                fail[i]=tmp+1;
            }

            int posText=0, subText=0;
            while(posText<mainStr.Length){
               if (subText==0 || mainStr[posText]==subs[subText]){
                   posText++;
                   subText++;
               } else {
                   subText = fail[subText];
               }

               if (posText<mainStr.Length && subText == subs.Length && subs[subText - 1] == mainStr[posText])
               {
                   count++;
                   subText = 0;
               }
               else subText = 0;
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif
            string mainStr = RL();

            for (int i = mainStr.Length - 1; i > 1; i--) {
                for (int j = 0; j < mainStr.Length - i; j++) {
                    string subs = mainStr.Substring(j, i);
                    int tmp = KMP(mainStr, subs);
                    if (tmp >= 2) {
                        println(subs.Length);
                        //close(file);
                        return;
                    }
                }
            }

            println(0);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count = 0;
            int[] fail = new int[subs.Length+1];

            fail[1] = 0;
            for(int i=2; i<=subs.Length; i++){
                int tmp=fail[i-1];
                while(tmp>0 && subs[tmp]!=subs[i-1]) tmp=fail[tmp];
                fail[i] = tmp + 1;
            }

            int posInText=0, posInSubs = 0;
            while (posInText < mainStr.Length) {
                if (posInSubs == 0 || mainStr[posInText] == subs[posInSubs])
                {
                    posInSubs++;
                    posInText++;
                } else {
                    posInSubs = fail[posInSubs];
                }

                if (posInSubs == subs.Length) {
                    count++;
                    posInText = posInText - posInSubs + 1;
                    posInSubs = 0;
                }
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            int res = -1;
            string s = RL()+"&";

            for (int i = s.Length - 1; i > 0; i--) {
                for (int j = 0; j <= s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    res = Math.Max(res, KMP(s, subs));
                }
            }

            if (res<2) println("0");
            else println(res);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count=0;
            int[] fail = new int[subs.Length + 1];

            fail[1]=0;
            for(int i=2; i<=subs.Length; i++){
                int tmp=fail[i-1];
                while(tmp>0 && subs[tmp]!=subs[i-1]) tmp=fail[tmp];
                fail[i]=tmp+1;
            }

            int posText=0, subText=0;
            while(posText<mainStr.Length){
               if (mainStr[posText]==subs[subText]){
                   posText++;
                   subText++;
               } else {
                   subText = fail[subText];
                   posText++;
               }

               if (subText == subs.Length) {
                   count++;
                   subText = 0;
               }
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            int res = -1;
            string s = RL();

            for (int i = s.Length - 1; i > 0; i--) {
                for (int j = 0; j < s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    res = Math.Max(res, KMP(s, subs));
                }
            }

            if (res<2) println("0");
            else println(res);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count=0;
            int[] fail = new int[subs.Length + 1];

            fail[0]=0;
            for(int i=1; i<subs.Length; i++){
                int tmp=fail[i-1];
                while(tmp>0 && subs[tmp]!=subs[i-1]) tmp=fail[tmp];
                fail[i]=tmp+1;
            }

            int posText=0, subText=0;
            while(posText<mainStr.Length){
               if (mainStr[posText]==subs[subText]){
                   posText++;
                   subText++;
               } else {
                   subText = fail[subText];
               }

               if(subText==subs.Length){
                    count++;
                    subText=0;
               }

               posText++;
            }

            return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;

namespace acm{
    class Program{
        static void Main(string[] args){
            System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
#if DEBUG
            open(file);
#endif

            int res = -1;
            string s = RL()+"&";

            for (int i = s.Length - 1; i > 0; i--) {
                for (int j = 0; j <= s.Length - i; j++) {
                    string subs = s.Substring(j, i);
                    res = Math.Max(res, KMP(s, subs));
                }
            }

            if (res<2) println("0");
            else println(res);

#if DEBUG
                close(file);
#endif
        }

        static int KMP(string mainStr, string subs) {
            int count = 0;

            for (int i = 0; i < mainStr.Length-subs.Length; i++) {
                bool flag = true;
                for (int j = 0; j < subs.Length; j++) {
                    if (subs[j] != mainStr[i]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) count++;
            }

                return count;
        }

#if DEBUG
        static bool file = true;
        static TextReader fin = new StreamReader("input.txt");
        static TextWriter fout = new StreamWriter("output.txt");
        static void open(bool f) { if (f) { Console.SetIn(fin); Console.SetOut(fout); } }
        static void close(bool f) { if (f) fout.Close(); }
#endif
        struct pair<T1, T2> { public T1 first; public T2 second; }
        static void fill<T>(T[] d, T val) { for (int i = 0; i < d.Length; i++) d[i] = val; }
        static void fill<T>(List<T> d, T val) { for (int i = 0; i < d.Count; i++) d[i] = val; }
        static void swap<T>(List<T> l, int a, int b) { T tmp = l[a]; l[a] = l[b]; l[b] = tmp; }
        static void swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int readInt() { return int.Parse(RL()); }
        static void print(object o) { Console.Write(o); }
        static void print(String f, params object[] o) { Console.Write(f, o); }
        static void println() { Console.WriteLine(); }
        static void println(object o) { Console.WriteLine(o); }
        static void println(String f, params object[] o) { Console.WriteLine(f, o); }
        static string RL() { return Console.ReadLine(); }
        static int RC() { return Console.Read(); }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class CF_23A
{
    static void Main()
    {
        string str = Console.ReadLine();
        int len;
        for (len = str.Length; len >= 0; len--)
        {
            for (int i = 0; i + len <= str.Length; i++)
            {
                string sub = str.Substring(i, len);
                int cnt = 0;
                for (int p = str.IndexOf(sub, 0) ; p < str.Length && p != -1; p = str.IndexOf(sub, ++p))
                {
                    cnt++;
                    if (cnt >= 2)
                    {
                        Console.WriteLine(len);
                        return;
                    }
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                int mlen = 0;
                for (int j = 0; j < line.Length; j++)
                {
                    int len = 0;
                    for (int i = j+1; i < line.Length - j; i++)
                    {
                        int lmlen = comp(line, j, i);
                        if (lmlen > len) len = lmlen;
                    }
                    if (len > mlen) mlen = len;
                }
                Console.WriteLine(mlen);
            }
        }
        static int comp(string str, int i, int j)
        {
            int len = 0;
            while (i < str.Length && j < str.Length)
            {
                if (str[i] != str[j]) return len;
                i++; j++; len++;
            }
            return len;
        }
    }
}

using System;
using System.IO;

namespace q1
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader tr = Console.In;
            string buf = tr.ReadLine();
            int max = 0;
            string sub;
            for (int i = 0; i < buf.Length; i++)
            {
                for (int j = 2; i + j <= buf.Length; j++)
                {
                    sub = buf.Substring(i, j);
                    if ((buf.Substring(i+1)).Contains(sub))
                    {
                        if (max < sub.Length)
                        {
                            max = sub.Length;
                        }
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.IO;

namespace q1
{
    class Program
    {
        static void Main(string[] args)
        {
            TextReader tr = Console.In;
            string buf = tr.ReadLine();
            int max = 0;
            string sub;
            for (int i = 0; i < buf.Length; i++)
            {
                for (int j = 2; i + j < buf.Length; j++)
                {
                    sub = buf.Substring(i, j);
                    if ((buf.Substring(i+1)).Contains(sub))
                    {
                        if (max < sub.Length)
                        {
                            max = sub.Length;
                        }
                    }
                }
            }
            Console.WriteLine(max);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int max = 0;
            int d = 1; //как бэ сдвиг
            bool b = false;
            for (; d < s.Length; d++)
            {
                int cnt = 0;
                int cnt2 = 0;
                for (int i = d; i < s.Length; i++)
                {
                    if (s[i - d] == s[i])
                    {
                        if (b == false)
                        {
                            b = true;
                            cnt2 = Math.Max(cnt, cnt2);
                            cnt = 0;
                        }
                        cnt++;
                    }
                }
                max = Math.Max(Math.Max(cnt, cnt2), max);
            }
            Console.WriteLine(max);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int max = 0;
            int d = 1; //как бэ сдвиг
            for (; d < s.Length; d++)
            {
                int cnt = 0;
                for (int i = d; i < s.Length; i++)
                {
                    if (s[i - d] == s[i])
                        cnt++;
                }
                if (max < cnt)
                    max = cnt;
            }
            Console.WriteLine(max);
            Console.ReadLine();
        }
    }
}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

namespace FirstApp
{

    class Program
    {

        static void Main(string[] args)
        {

            string[] substr = new string[10000];

            int[] count = new int[10000];

            int num = 0;

            string str = Console.ReadLine();
          //  string str = "ababa";

            bool check;

            for (int i = 0; i < 10000; i++)
            {

                count[i] = 0;

            }

            for (var i = 0; i < str.Length; i++)
            {

                StringBuilder tmp = new StringBuilder("", 1000);

                for (var j = i; j < str.Length; j++)
                {

                    tmp.AppendFormat(Convert.ToString(str[j]));

                    if (tmp.Length > 1)
                    {

                        //проверяем есть ли значение в массиве подстрок

                        check = true;

                        for (var m = 0; m < num; m++)
                        {

                            if (String.Compare(Convert.ToString(tmp), Convert.ToString(substr[m]), true) == 0)
                            {

                                check = false;

                            }

                        }

                        //проверяем на уникальность и добавим в массив подстроки

                        if (check == true)
                        {

                            substr[num] = Convert.ToString(tmp);

                            num++;

                        }

                    }

                }

            }

            //Тест покажем подстроки
            for (var r = 0; r < num; r++)
            {
                // Console.WriteLine(substr[r]);
            }

            //начинаем поиск

            //string rrrr = "ababa";
            //Console.WriteLine(str.IndexOf("ab",2));

            for (var r = 0; r < num; r++)
            {
                int pos = -1; //позтция

               // Console.WriteLine("KEY ========= " + substr[r] + " ==========");
                for (int st = 0; st < str.Length; st++)
                {

                    int index = str.IndexOf(substr[r], st);

                    //Console.WriteLine("STEP" + st + "=");

                    if (index > -1 && pos != index)
                    {

                        count[r] = count[r] + 1;

                       // Console.WriteLine("=" + substr[r] + "=");
                        pos = index;
                        //Console.WriteLine(st);
                    }

                    //   Console.WriteLine(substr[r]);
                }

            }

            //отбираем самую большую подстроку
            int symcount = 0;
            for (var r = 0; r < num; r++)
            {
                if (count[r] > 1)
                {
                   // Console.WriteLine(count[r]);
                    if (substr[r].Length > symcount)
                    {
                        symcount = substr[r].Length;
                    }
                }
            }

            Console.WriteLine(symcount);

        //    Console.ReadKey();

        }

        //  static bool Check(string tmp){

        //      return true;

        //   }

    }

}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            string tmpStr;
            string podstr;
            string otvet="";

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            Console.WriteLine(otvet);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            //string str = GetString();
            string str = "abcd";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            //string str = "abcd";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
           //string str = "ababa";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+1);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
           // string str = "abcd";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i <= str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {
                    if (i + g == 0) continue;
                    tmpStr = str.Substring(i+g-1);
                    podstr = str.Substring(i,g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            //string str = "a";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length+1; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
           //string str = "aaaaaaaa";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length <= podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            string tmpStr;
            string podstr;
            string otvet="";

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            Console.WriteLine(otvet.Length);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            //string str = GetString();
            string str = "ababa";
            string tmpStr;
            string podstr;
            string otvet="^";

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }
            int count;
            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
           // string str = "abcd";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            //string str = "a";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            if (str.Length == 1) count = 1;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
           // string str = "abcd";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i <= str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            //string str = GetString();
            string str = "ababa";
            string tmpStr;
            string podstr;
            string otvet = "^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for (int g = 1; g < str.Length - i; g++)
                {

                    tmpStr = str.Substring(i + 1);
                    podstr = str.Substring(i, g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if (otvet.Length <= podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            //string str = GetString();
           string str = "ababa";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+1);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            string tmpStr;
            string podstr;
            string otvet="^";

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=1; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }
            int count;
            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            string tmpStr;
            string podstr;
            string otvet="^";

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }
            int count;
            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            //string str = GetString();
            string str = "asdgsfcgsdbsdtczsdx zvv bxcdxfvsczzxcvgvbjfghjdcthvhbdcsertsecsdvxdbcgcxgxd jxfcdgxfhxdfhxdhdhxfgnbxmjncjbcmgbxf";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i <= str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+g);
                    podstr = str.Substring(i,g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length < podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            //string str = GetString();
            string str = "abcd";
            string tmpStr;
            string podstr;
            string otvet="^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for(int g=0; g < str.Length-i; g++)
                {

                    tmpStr = str.Substring(i+1);
                    podstr = str.Substring(i,g+1);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if(otvet.Length <= podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Program1
{
    class Program
    {

        static int Main(string[] args)
        {

            string str = GetString();
            //string str = "";
            string tmpStr;
            string podstr;
            string otvet = "^";
            int count;

            for (int i = 0; i < str.Length; i++)
            {
                for (int g = 1; g < str.Length - i; g++)
                {

                    tmpStr = str.Substring(i + g);
                    podstr = str.Substring(i, g);

                    if (tmpStr.IndexOf(podstr) > -1)
                    {
                        if (otvet.Length <= podstr.Length)
                        {
                            otvet = podstr;
                        }
                        else continue;

                    }
                    else
                    {
                        break;
                    }

                }

            }

            if (otvet == "^") count = 0; else count = otvet.Length;
            Console.WriteLine(count);

            return 0;
        }

        static string GetString()
        {
            return Console.ReadLine();
        }

    }
}