#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
char s[MAX_N + 4];
int ats[MAX_N];
int countuser(int k) {
  int cnt = 0;
  k--;
  while (k >= 0 && (islower(s[k]) || isdigit(s[k]) || s[k] == '_')) {
    if (islower(s[k])) cnt++;
    k--;
  }
  return cnt;
}
int countdomain(int k) {
  k++;
  int l = 0;
  while (islower(s[k]) || isdigit(s[k])) l++, k++;
  if (l == 0 || s[k] != '.') return 0;
  k++;
  int cnt = 0;
  while (islower(s[k])) cnt++, k++;
  return cnt;
}
int main() {
  scanf("%s", s);
  int n = strlen(s);
  long long sum = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == '@') {
      int cu = countuser(i);
      int cd = countdomain(i);
      sum += (long long)cu * cd;
    }
  printf("%lld\n", sum);
  return 0;
}
