#include <bits/stdc++.h>
using namespace std;
const int N = 1000050;
char s[N];
int n;
int L[N], alf[N], R[N], r[N];
int max(int a, int b) {
  if (a > b) return a;
  return b;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  int stop = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == '@') L[i] = alf[i - 1] - alf[stop];
    if (s[i] == '@' || s[i] == '.') stop = i;
    alf[i] = alf[i - 1];
    if (s[i] >= 'a' && s[i] <= 'z') alf[i]++;
  }
  int dot = n + 1;
  stop = n + 1;
  int stop1 = n + 1;
  for (int i = n; i >= 1; i--) {
    if (s[i] == '.') {
      dot = i;
      r[i] = alf[stop - 1] - alf[i];
    }
    if (s[i] == '@') {
      if (stop1 == dot && dot != i + 1) R[i] = r[dot];
    }
    if (s[i] < 'a' || s[i] > 'z') stop = i;
    if (s[i] < 'a' || s[i] > 'z')
      if (s[i] < '0' || s[i] > '9') stop1 = i;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += 1ll * L[i] * R[i];
  printf("%I64d\n", ans);
}
