#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
    string s;
    cin >> s;
    ll ans = 0,r=-1,e=-1,d=-1;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'r') {
            r = i;
        }
        else if (s[i] == 'e')e = i;
        else if (s[i] == 'd')d = i;
     
        int g = min(r, e);
        if (g > d) {
            ans += g - d;
        }
    }
    cout << ans << endl;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //int t = 1; cin >> t; while (t--)
    solve();
    return 0;
}