#include <bits/stdc++.h>
using namespace std;
char S[1000010];
int alpha[1000010];
int main() {
  int n;
  long long ans = 0;
  scanf("%s", S);
  n = strlen(S);
  for (int i = 0, al = 0; i < n; ++i) {
    if (isalpha(S[i]))
      ++al;
    else if (isdigit(S[i]) || S[i] == '_')
      continue;
    else if (S[i] == '.')
      al = 0;
    else {
      alpha[i] = al;
      al = 0;
    }
  }
  bool fix = false;
  for (int i = n - 1, dot1 = 0, dot2 = 0, num = 0; i >= 0; --i) {
    if (isalpha(S[i])) {
      if (!fix)
        ++dot1;
      else
        ++dot2;
    } else if (isdigit(S[i])) {
      if (!fix)
        dot1 = 0;
      else
        dot2 = 0;
    } else if (S[i] == '_') {
      dot1 = dot2 = 0;
      fix = false;
    } else if (S[i] == '.') {
      if (fix) dot1 = dot2, dot2 = 0;
      fix = true;
    } else {
      if (fix && S[i + 1] != '.') ans += (long long)alpha[i] * dot1;
      fix = false;
      dot1 = dot2 = 0;
    }
  }
  printf("%I64d", ans);
  return 0;
}
