#include <bits/stdc++.h>
using namespace std;
long long d[1000050][5];
char s[1000050];
int main() {
  int n;
  long long ans = 0;
  scanf(" %s", s);
  n = strlen(s);
  for (int i = 1; i <= n; ++i) {
    if (s[i - 1] == '@') {
      d[i][1] = d[i - 1][0];
    } else if (s[i - 1] == '.') {
      d[i][3] = d[i - 1][2];
    } else if (s[i - 1] == '_') {
      d[i][0] = d[i - 1][0];
    } else if (s[i - 1] >= '0' && s[i - 1] <= '9') {
      d[i][0] = d[i - 1][0];
      d[i][2] = d[i - 1][1] + d[i - 1][2];
    } else {
      d[i][0] = d[i - 1][0] + 1;
      d[i][2] = d[i - 1][1] + d[i - 1][2];
      d[i][4] = d[i - 1][3] + d[i - 1][4];
    }
    ans += d[i][4];
  }
  printf("%I64d\n", ans);
}
