#include <iostream>
#include <algorithm>

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 najnizi[3];

    do {
        najnizi[0], najnizi[1] = -1, -1, -1;
        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;
                    if (najnizi[1] == -1) najnizi[1] = dist;
                    //std::cout << "DIST: " << dist << "\n";

                    if (dist % 2 == 1 && dist <= najnizi[1]) {

                        najnizi[0] = i;
                        najnizi[1] = dist;
                        //std::cout << "0: " << najnizi[0] << "\t1:" << najnizi[1] << "\n\n";
                    }
                                    
                }
            }
        }
        
        std::string recnov = rec;
        recnov.insert(najnizi[0] + najnizi[1] / 2 + 1, " ");

        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) {
                    dist = index - i;
                    //std::cout << "pi: " << i << "\tpdist: " << dist << std::endl;
                    if ((dist % 2 == 0) && (recnov[i + dist / 2] == ' ')) skor++;

                }
            }
        }

        if (skor >= najnizi[2]) {
            rec = recnov;
            najnizi[2] = skor;
        }
        else break;

        //std::cout << rec << "\t" << najnizi[2] << "\n";
       
        
    } while ((najnizi[0] != -1));

    //std::cout << rec;
    std::cout << najnizi[2];

    
    
}