#include <iostream>
#include <algorithm>

std::string spacechar = " "; //mora kao string zbog eto tako ne radi ako nije

int main()
{
    // index izmedju je neparan
    // index izmedju = 2 * index do kraja reda + 1
    //posle indexa do kraja reda dodati neki simbol koji oznacava novi red
    //posle dodavanja simbola razmak treba bude paran
    std::string rec;
    std::cin >> rec;

    int nIndex, nLength, nScore;
    nScore = 0;

    do {
        nIndex = -1;
        nLength = 3001;
        
        int duzina = rec.length();

        //std::cout << "Duzina: " << duzina << std::endl;
        int dist;
        for (int i = 0; i < duzina; ++i) {
            if (rec[i] != ' ') {
                std::size_t index = rec.find(rec[i], i + 1);
                //std::cout << "i: " << i << "\tindex: " << index << std::endl;
                
                if (index != std::string::npos) {
                    dist = index - i;
                    //std::cout << "DIST: " << dist << "\tNAJNIZI1: " << nLength << "\n";

                    if (dist % 2 == 1 && dist <= nLength) {

                        nIndex = i;
                        nLength = dist;
                        //std::cout << "0: " << nIndex << "\t1:" << nLength << "\n\n";
                    }
                                    
                }
            }
        }
        
        std::string recnov = rec;
        if (nIndex > -1 && nLength <= duzina) recnov.insert(nIndex + nLength / 2 + 1, spacechar);
        else {
            std::cout << nScore;
            return 0;
        }

        int skor = 0;
        for (int i = 0; i < duzina; ++i) {
            if (rec[i] != '0') {
                std::size_t index = recnov.find(recnov[i], i + 1);

                if (index != std::string::npos) {
                    std::size_t indexspace = i;
                    bool loop = true;
                    int spacecount = 0;
                    while (loop) {
                        indexspace = recnov.find(spacechar, indexspace + 1);
                        //std::cout << "i: " << i << "\tspace index: " << indexspace << "\n";
                        if (indexspace != std::string::npos && indexspace < index) spacecount++;
                        else loop = false;
                    }

                    dist = index - i;
                    //std::cout << "pi: " << i << "\tpdist: " << dist << std::endl;
                    if ((dist % 2 == 0) && (recnov[i + dist / 2] == spacechar[0]) && (spacecount < 2)) skor++;

                }
            }
        }

        //std::cout << recnov << "\t" << skor << "\tnajnizi:" << nScore << "\n";
        if (skor > nScore) {
            rec = recnov;
            nScore = skor;
        }
        else {
            std::cout << nScore;
            return 0;
        }

        
       
        
    } while ((nIndex != -1));


    
    
}