package ru.redguy.tasks;

import ru.redguy.ATask;
import ru.redguy.Task;

import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;

@ATask("2509")
public class Task2509 extends Task {
    @Override
    public void run() throws IOException {
        String s = getFile("24.txt");
        int line = 0;
        for (int i = 0; i < s.length(); i++) {
            int bingo = 0;
            for (int j = i; j < s.length(); j++) {
                try {
                    String sub = s.substring(j, j + 3);
                    if (sub.charAt(0) == sub.charAt(1) && sub.charAt(1) == sub.charAt(2)) {
                        bingo++;
                    } else {
                        if (line < bingo) line = bingo;
                        break;
                    }
                } catch (StringIndexOutOfBoundsException e) {
                    if (line < bingo) line = bingo;
                    break;
                }
            }
        }
        System.out.println(line);
    }
}