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.io.*;
import java.nio.CharBuffer;
import java.util.LinkedList;
import java.util.NoSuchElementException;

public class P1169D_2 {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        char[] s = scanner.next().toCharArray();
        int n = s.length;
        long ans = 0;
        int r = n;
        LinkedList<Integer>[] pos = new LinkedList[2];
        pos[0] = new LinkedList<>();
        pos[1] = new LinkedList<>();
        for (int x = n - 1; x >= 0; --x) {
            for (int mid : pos[s[x] - '0']) {
                if (x + 2 * (mid - x) >= r)
                    break;
                if (s[mid] == s[x + 2 * (mid - x)]) {
                    r = x + 2 * (mid - x);
                    break;
                }
            }
            ans += n - r;
            pos[s[x] - '0'].addFirst(x);
        }
        writer.println(ans);
        writer.close();
    }

    private static boolean test(int[] x, int k, int m) {
        int n = x.length;
        int pre = 0;
        for (int value : x) {
            if (value + k < m) {
                if (value + k < pre)
                    return false;
                pre = Math.max(value, pre);
            } else {
                if (pre < value && pre > (value + k) % m)
                    pre = value;
            }
        }
        return true;
    }

    private static boolean testOne(int[][] pair, int base, int x) {
        int m = pair.length;
        for (int i = base; i < m; ++i) {
            if (pair[i][0] != x && pair[i][1] != x) {
                return testTwo(pair, i, x, pair[i][0]) || testTwo(pair, i, x, pair[i][1]);
            }
        }
        return true;
    }

    private static boolean testTwo(int[][] pair, int base, int x, int y) {
        int m = pair.length;
        for (int i = base; i < m; ++i) {
            if (pair[i][0] != x && pair[i][0] != y && pair[i][1] != x && pair[i][1] != y) {
                return false;
            }
        }
        return true;
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}