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