Problem: Toad Rash has a binary string s. A binary string consists only of zeros and ones.

Let n be the length of s.

Rash needs to find the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x, k ≤ n, l ≤ x < x + 2k ≤ r, and s_x = s_{x+k} = s_{x+2k}.

Find this number of pairs for Rash.

Input

The first line contains the string s (1 ≤ |s| ≤ 300 000), consisting of zeros and ones.

Output

Output one integer: the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x, k ≤ n, l ≤ x < x + 2k ≤ r, and s_x = s_{x+k} = s_{x+2k}.

Examples

Input


010101


Output


3


Input


11001100


Output


0

Note

In the first example, there are three l, r pairs we need to count: 1, 6; 2, 6; and 1, 5.

In the second example, there are no values x, k for the initial string, so the answer is 0.

Solution (in JAVA):

Solution:
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;



public class Main {

    public static void main(String[] args) throws Exception {
        IO io ;
        try {
            io = new IO("in.in", null);
        } catch (IOException e) {
            io = new IO(null, null);
        }
        char [] S = io.getNext().toCharArray();
        int n = S.length;
        int l = -1;
        long ans = 0;
        TreeSet<Integer> [] TS = new TreeSet[2];
        for (int b = 0;b < 2;b++)
            TS[b] = new TreeSet<>();
        for (int r = 0;r < n;r++) {
            int b = S[r] - '0';
            while (!TS[b].isEmpty() && TS[b].first() <= l)
                TS[b].pollFirst();
            int ctr = 0;
            for (int i : TS[b].descendingSet()) {
                ctr++;
                if ((r - i)%2 == 1) continue;
                int k = (r - i)/2;
                if (S[i + k] == S[r]) {
                    l = i;
                    break;
                }
                if (ctr == 64) break;
            }
//            if (l > -1)
//                System.err.println((l+1) + " " + (r+1));
            ans += l+1;
            TS[b].add(r);
        }
        System.err.println(TS[0] + " " + TS[1]);
        io.println(ans);
        io.close();
    }
    private static final int onebillion7 = 1000000007;
}


class pair implements Comparable<pair>{
    int k,s;
    public pair(int a,int b) {
        k = a;
        s = b;
    }

    @Override
    public int compareTo(pair o) {
        if (k == o.k) return (s - o.s);
        return (k - o.k);
    }
}

class IO{
    private BufferedReader br;
    private StringTokenizer st;
    private PrintWriter writer;
    private String inputFile,outputFile;

    public boolean hasMore() throws IOException{
        if(st != null && st.hasMoreTokens()) return true;
        if(br != null && br.ready()) return true;
        return false;
    }

    public String getNext() throws FileNotFoundException, IOException{
        while(st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String getNextLine() throws FileNotFoundException, IOException{
        return br.readLine().trim();
    }

    public int getNextInt() throws FileNotFoundException, IOException{
        return Integer.parseInt(getNext());
    }
    public long getNextLong() throws FileNotFoundException, IOException{
        return Long.parseLong(getNext());
    }

    public void print(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f" ,x);
    }
    public void println(double x,int num_digits) throws  IOException{
        writer.printf("%." + num_digits + "f\n" ,x);
    }
    public void print(Object o) throws  IOException{
        writer.print(o.toString());
    }

    public void println(Object o) throws  IOException{
        writer.println(o.toString());
    }
    public IO(String x,String y) throws FileNotFoundException, IOException{
        inputFile = x;
        outputFile = y;
        if(x != null) br = new BufferedReader(new FileReader(inputFile));
        else br = new BufferedReader(new InputStreamReader(System.in));
        if(y != null) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile)));
        else writer = new PrintWriter(new OutputStreamWriter(System.out));
    }

    protected void close() throws IOException{
        br.close();
        writer.close();
    }
    public void outputArr(Object [] A) throws IOException{
        int L = A.length;
        for (int i = 0;i < L;i++) {
            if(i > 0) writer.print(" ");
            writer.print(A[i]);
        }
        writer.print("\n");
    }
}



//class PollardRho {
//    private final static BigInteger ZERO = new BigInteger("0");
//    private final static BigInteger ONE  = new BigInteger("1");
//    private final static BigInteger TWO  = new BigInteger("2");
//    private final static SecureRandom random = new SecureRandom();
//    private static ArrayList<Long> primes = new ArrayList<>();
//
//    private static BigInteger rho(BigInteger N) {
//        BigInteger divisor;
//        BigInteger c  = new BigInteger(N.bitLength(), random);
//        BigInteger x  = new BigInteger(N.bitLength(), random);
//        BigInteger xx = x;
//
//        // check divisibility by 2
//        if (N.base(TWO).compareTo(ZERO) == 0) return TWO;
//
//        do {
//            x  =  x.multiply(x).base(N).add(c).base(N);
//            xx = xx.multiply(xx).base(N).add(c).base(N);
//            xx = xx.multiply(xx).base(N).add(c).base(N);
//            divisor = x.subtract(xx).gcd(N);
//        } while((divisor.compareTo(ONE)) == 0);
//
//        return divisor;
//    }
//
//    private static void factor(BigInteger N) {
//        if (N.compareTo(ONE) == 0) return;
//        if (N.isProbablePrime(20)) {
//            primes.add(N.longValue());
//            return;
//        }
//        BigInteger divisor = rho(N);
//        factor(divisor);
//        factor(N.divide(divisor));
//    }
//
//
//    public static ArrayList<Long> factor(Long n) {
//        primes.clear();
//        factor(BigInteger.valueOf(n));
//        return primes;
//    }
//}

class complex{
    BigDecimal real,imag;
    private static DecimalFormat df = new DecimalFormat("#.###");
    public complex(double x,double y){
        real = new BigDecimal(x);
        imag = new BigDecimal(y);
    }
    public complex(BigDecimal x,BigDecimal y) {
        real = new BigDecimal(x.toString());
        imag = new BigDecimal(y.toString());
    }
    public complex(double t) {
        real = new BigDecimal(Math.cos(t));
        imag = new BigDecimal(Math.sin(t));
    }
    public complex add(complex o){
        return new complex(real.add(o.real),imag.add(o.imag));
    }
    public complex sub(complex o) {
        return new complex(real.subtract(o.real),imag.subtract(o.imag));
    }
    public complex mult(double c) {
        BigDecimal bc = new BigDecimal(c);
        return new complex(real.multiply(bc),imag.multiply(bc));
    }
    public complex mult(complex o) {
        BigDecimal a = real.multiply(o.real).subtract(imag.multiply(o.imag));
        BigDecimal b = real.multiply(o.imag).add(imag.multiply(o.real));
        return new complex(a,b);
    }
    public complex divide(complex o) {
        return this.mult(new complex(o.real,o.imag.negate())).divide(o.norm2());
    }
    public complex divide(double c) {
        BigDecimal bc = new BigDecimal(c);
        return new complex(real.divide(bc),imag.divide(bc));
    }
    public complex divide(BigDecimal bc) {
        return new complex(real.divide(bc),imag.divide(bc));
    }

    public BigDecimal norm2(){
        return real.multiply(real).add(imag.multiply(imag));
    }
    public double norm(){
        return Math.sqrt(norm2().doubleValue());
    }
    @Override
    public String toString(){
        return "(" + df.format(real) + ", " + df.format(imag) + ")";
    }
}

class FFT{
    public static long [] mult(long [] A,long [] B) {
        int n = A.length;
        while (n != (n & -n)) n++;
        n <<= 1;
        complex [] pA = new complex[n];
        complex [] pB = new complex[n];
        complex [] pC = new complex[n];
        for (int i = 0;i < n;i++) {
            if (i < A.length){
                pA[i] = new complex(A[i],0);
                pB[i] = new complex(B[i],0);
            }
            else {
                pA[i] = new complex(0,0);
                pB[i] = new complex(0,0);
            }
        }

        pA = fft(pA,false);
        pB = fft(pB,false);
        for (int i = 0;i < pC.length;i++)
            pC[i] = pA[i].mult(pB[i]);
        pC = fft(pC,true);
        long [] C = new long[n];
        for (int i = 0;i < n;i++) {
            long mod = 1000*1000*1000;
            BigDecimal bc = pC[i].real.remainder(new BigDecimal(mod));
            C[i] %= Math.round(bc.doubleValue());
        }
        return C;
    }
    private static complex[] fft(complex [] f,boolean inv) {
        if (f.length == 1) return f;
        int n = f.length;
        complex wn = new complex((inv ? -1 : 1)*2*Math.PI/n),w = new complex(1,0);
        complex [] E = new complex[n/2],O = new complex[n/2];
        for (int i = 0;i < n;i++){
            if (i%2 == 0) E[i >> 1] = f[i];
            else O[i >> 1] = f[i];
        }
        E = fft(E,inv);
        O = fft(O,inv);
        for (int k = 0;k < n/2;k++){
            f[k] = E[k].add(w.mult(O[k]));
            f[k+n/2] = E[k].sub(w.mult(O[k]));
            w = w.mult(wn);
        }
        return f;
    }
}