import std.stdio, std.string, std.conv, std.array, std.algorithm, std.math;

long calc(long x) {
    return x * (x + 1) / 2;
}

void main() {
    string s = readln.chomp;
    auto g = s.group.array;
    long[] a = new long[(g.length+1)/2*2];
    foreach (i, x; g) {
        a[i] = x[1];
    }
    long ans;
    for (auto i = 0; i < a.length; i += 2) {
        if (a[i] < a[i+1]) {
            ans += calc(a[i]-1) + calc(a[i+1]);
        } else {
            ans += calc(a[i]) + calc(a[i+1]-1);
        }
    }
    ans.writeln;
}