#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int dr[1000005], drr[1000005], a[1000005], b[1000005];
int main() {
  long long sol = 0;
  int i, stg, drp, N;
  cin >> (s + 1);
  N = strlen(s + 1);
  for (i = N; i; --i)
    if (s[i] == '.')
      dr[i] = i;
    else
      dr[i] = dr[i + 1];
  for (i = N; i; --i)
    if (s[i] == '.' || s[i] == '_' || s[i] == '@')
      drr[i] = i;
    else
      drr[i] = drr[i + 1];
  for (i = N; i; --i)
    if (!(s[i] >= 'a' && s[i] <= 'z'))
      a[i] = 0;
    else
      a[i] = 1 + a[i + 1];
  for (i = 1; i <= N; ++i)
    if (s[i] == '@' || s[i] == '.')
      b[i] = 0;
    else {
      b[i] = b[i - 1];
      if (s[i] >= 'a' && s[i] <= 'z') ++b[i];
    }
  for (i = 1; i <= N; ++i)
    if (s[i] == '@' && dr[i + 1]) {
      stg = i;
      drp = dr[i + 1];
      if (drr[stg + 1] < drp || drp == stg + 1) continue;
      sol += 1LL * a[drp + 1] * b[stg - 1];
    }
  cout << sol << "\n";
  return 0;
}
