Problem: The bear has a string s = s1s2... s|s| (record |s| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i, j (1 ≤ i ≤ j ≤ |s|), that string x(i, j) = sisi + 1... sj contains at least one string "bear" as a substring.

String x(i, j) contains string "bear", if there is such index k (i ≤ k ≤ j - 3), that sk = b, sk + 1 = e, sk + 2 = a, sk + 3 = r.

Help the bear cope with the given problem.

Input

The first line contains a non-empty string s (1 ≤ |s| ≤ 5000). It is guaranteed that the string only consists of lowercase English letters.

Output

Print a single number — the answer to the problem.

Examples

Input

bearbtear


Output

6


Input

bearaabearc


Output

20

Note

In the first sample, the following pairs (i, j) match: (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9).

In the second sample, the following pairs (i, j) match: (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, 10), (2, 11), (3, 10), (3, 11), (4, 10), (4, 11), (5, 10), (5, 11), (6, 10), (6, 11), (7, 10), (7, 11).

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Main().new Scanner(inputStream);
		Writer out = new Main().new Writer(outputStream);
		Main solver = new Main();
		solver.solve(in, out);
	}

	public void solve(Scanner in, Writer out) {
		String s = in.readLine();
		List<Integer> pos = new ArrayList<>();
		for (int i = 0; i <= s.length() - 4; i++) {
			if(s.substring(i, i + 4).equals("bear")) {
				pos.add(i);
			}
		}
		long total = 0;
		for (int i = 0; i < pos.size(); i++) {
			long before = -1;
			long after = -1;
			int ind = pos.get(i);
			if(i == 0) {
				before = ind + 1;
			} else {
				before = ind - pos.get(i - 1);
			}
			if(i == pos.size() - 1) {
				after = s.length() - ind - 4 + 1;
			} else {
				after = s.length() - ind - 4 + 1;
			}
			total += before * after;
		}
		System.out.println(total);
	}
	
	public int[] strToIntArr(String[] arr) {
		return Stream.of(arr).mapToInt(Integer::parseInt).toArray();
	}

	public boolean deq(double a, double b) {
		return Math.abs(a - b) < 0.0001;
	}

	public double dist(double a, double b, double c, double d) {
		return Math.sqrt((a - c) * (a - c) + (b - d) * (b - d));
	}

	public boolean hasMore(String line) {
		return line != null && !line.equals("");
	}

	public int max(int a, int b, int c) {
		return Math.max(a, Math.max(b, c));
	}

	public int min(int a, int b, int c) {
		return Math.min(a, Math.min(b, c));
	}

	class Writer {
		PrintWriter output;

		public Writer(OutputStream out) {
			this.output = new PrintWriter(new OutputStreamWriter(out));
		}

		public void println(Object s) {
			output.println(s.toString());
		}

		public void print(Object s) {
			output.print(s.toString());
		}

		public void flush() {
			output.flush();
		}
	}

	class Scanner {
		BufferedReader br;
		StringTokenizer in;

		public Scanner(InputStream inputStream) {
			br = new BufferedReader(new InputStreamReader(inputStream));
		}

		public String next() {
			return hasMoreTokens() ? in.nextToken() : null;
		}

		public String readLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
				return null;
			}
		}

		boolean hasMoreTokens() {
			while (in == null || !in.hasMoreTokens()) {
				String s = readLine();
				if (s == null)
					return false;
				in = new StringTokenizer(s);
			}
			return true;
		}

		public String nextString() {
			return next();
		}

		public int ni() {
			return Integer.parseInt(nextString());
		}

		public double nd() {
			return Double.parseDouble(nextString());
		}

		public long nl() {
			return Long.parseLong(nextString());
		}

		public int[] nia(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public long[] nla(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}
	}

	class Pair implements Comparable<Pair> {
		long _first, _second;

		public Pair(int f, int s) {
			_first = f;
			_second = s;
		}

		public Pair(Long f, Long s) {
			_first = f;
			_second = s;
		}

		public int compareTo(Pair o) {
			if (this.first() != o.first())
				return Long.compare(this.first(), o.first());
			else
				return Long.compare(this.second(), o.second());
		}

		long first() {
			return _first;
		}

		long second() {
			return _second;
		}

		int firsti() {
			return (int) _first;
		}

		int secondi() {
			return (int) _second;
		}
	}

	class Triple implements Comparable<Triple> {
		Integer _first, _second, _third;

		public Triple(Integer f, Integer s, Integer t) {
			_first = f;
			_second = s;
			_third = t;
		}

		public int compareTo(Triple o) {
			if (!this.first().equals(o.first()))
				return this.first() - o.first();
			else if (!this.second().equals(o.second()))
				return this.second() - o.second();
			else
				return this.third() - o.third();
		}

		Integer first() {
			return _first;
		}

		Integer second() {
			return _second;
		}

		Integer third() {
			return _third;
		}

		public String toString() {
			return first() + " " + second() + " " + third();
		}
	}

	class UnionFind {
		private ArrayList<Integer> p, rank, setSize;
		private int numSets;

		public UnionFind(int N) {
			p = new ArrayList<>(N);
			rank = new ArrayList<>(N);
			setSize = new ArrayList<>(N);
			numSets = N;
			for (int i = 0; i < N; i++) {
				p.add(i);
				rank.add(0);
				setSize.add(1);
			}
		}

		public int find(int i) {
			if (p.get(i) == i)
				return i;
			else {
				int ret = find(p.get(i));
				p.set(i, ret);
				return ret;
			}
		}

		public boolean connected(int i, int j) {
			return find(i) == find(j);
		}

		public void union(int i, int j) {
			if (!connected(i, j)) {
				numSets--;
				int x = find(i), y = find(j);
				if (rank.get(x) > rank.get(y)) {
					p.set(y, x);
					setSize.set(x, setSize.get(x) + setSize.get(y));
				} else {
					p.set(x, y);
					setSize.set(y, setSize.get(y) + setSize.get(x));
					if (rank.get(x) == rank.get(y))
						rank.set(y, rank.get(y) + 1);
				}
			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int size(int i) {
			return setSize.get(find(i));
		}
	}

	class SegmentTree {
		private int[] st, A;
		private int n;
		private boolean min;

		public SegmentTree(int[] _A, boolean _min) {
			min = _min;
			A = _A;
			n = A.length;
			st = new int[4 * n];
			for (int i = 0; i < 4 * n; i++)
				st[i] = 0;
			build(1, 0, n - 1);
		}

		private int left(int p) {
			return p << 1;
		}

		private int right(int p) {
			return (p << 1) + 1;
		}

		private void build(int p, int L, int R) {
			if (L == R)
				st[p] = A[L]; // L
			else {
				build(left(p), L, (L + R) / 2);
				build(right(p), (L + R) / 2 + 1, R);
				int p1 = st[left(p)], p2 = st[right(p)];
				st[p] = p1 + p2; // ((min && A[p1] <= A[p2]) || (!min && A[p1] >= A[p2])) ? p1 : p2;
			}
		}

		private int rmq(int p, int L, int R, int i, int j) {
			if (i > R || j < L)
				return -1;
			if (L >= i && R <= j)
				return st[p];

			int p1 = rmq(left(p), L, (L + R) / 2, i, j);
			int p2 = rmq(right(p), (L + R) / 2 + 1, R, i, j);

			if (p1 == -1)
				return p2;
			if (p2 == -1)
				return p1;
			return p1 + p2; // ((min && A[p1] <= A[p2]) || (!min && A[p1] >= A[p2])) ? p1 : p2;
		}

		private int update_point(int p, int L, int R, int idx, int new_value) {
			int i = idx, j = idx;

			if (i > R || j < L)
				return st[p];

			if (L == i && R == j) {
				A[i] = new_value;
				return st[p] = A[L];
			}

			int p1, p2;
			p1 = update_point(left(p), L, (L + R) / 2, idx, new_value);
			p2 = update_point(right(p), (L + R) / 2 + 1, R, idx, new_value);
			return st[p] = p1 + p2; // ((min && A[p1] <= A[p2]) || (!min && A[p1] >= A[p2])) ? p1 : p2;
		}

		public int rmq(int i, int j) {
			return rmq(1, 0, n - 1, i, j);
		}

		public int update_point(int idx, int new_value) {
			return update_point(1, 0, n - 1, idx, new_value);
		}
	}

}