#include <bits/stdc++.h>
using namespace std;
const int NMax = 1000010;
int n;
char a[NMax];
int arond[NMax];
int punct[NMax];
int talpa[NMax];
int letters[NMax];
long long ans;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> (a + 1);
  n = strlen(a + 1);
  talpa[n + 1] = arond[n + 1] = punct[n + 1] = n + 1;
  for (int i = n; i > 0; --i) {
    if (a[i + 1] == '@')
      arond[i] = i + 1;
    else
      arond[i] = arond[i + 1];
    if (a[i + 1] == '.')
      punct[i] = i + 1;
    else
      punct[i] = punct[i + 1];
    if (a[i + 1] == '_')
      talpa[i] = i + 1;
    else
      talpa[i] = talpa[i + 1];
    if ('a' <= a[i] && a[i] <= 'z')
      letters[i] = 1 + letters[i + 1];
    else
      letters[i] = 0;
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i] == '@' || a[i] == '.' || a[i] == '_' ||
        ('0' <= a[i] && a[i] <= '9'))
      continue;
    if ('a' <= a[i] && a[i] <= 'z') {
      if (arond[i] < punct[i]) {
        int j = arond[i];
        if (punct[j] < arond[j] && punct[j] - j > 1 && talpa[j] > punct[j]) {
          int k = punct[j];
          ans += 1LL * letters[k + 1];
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
