#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 7;
char s[N];
bool isdigit(char ch) {
  if (ch >= '0' && ch <= '9') return true;
  return false;
}
bool isalpha(char ch) {
  if (ch >= 'a' && ch <= 'z') return true;
  return false;
}
signed main(void) {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> (s + 1);
  long long n = strlen(s + 1);
  s[++n] = '@';
  long long op = 0, cnt[3] = {0};
  long long ans = 0;
  bool mid_flag = false;
  for (long long i = 1; i <= n; ++i) {
    if (op == 0) {
      if (isalpha(s[i])) {
        cnt[0]++;
      } else if (s[i] == '.') {
        cnt[0] = 0;
      } else if (s[i] == '@') {
        cnt[1] = 0;
        mid_flag = false;
        op = 1;
      }
    } else if (op == 1) {
      if (isalpha(s[i]) || isdigit(s[i])) mid_flag = true;
      if (s[i] == '_') {
        cnt[0] = cnt[1];
        cnt[1] = 0;
        op = 0;
      } else if (s[i] == '@') {
        cnt[0] = cnt[1];
        cnt[1] = 0;
        mid_flag = false;
        op = 1;
      } else if (s[i] == '.') {
        if (mid_flag) {
          cnt[2] = 0;
          op = 2;
        } else {
          cnt[0] = 0;
          op = 0;
        }
      } else if (isalpha(s[i])) {
        cnt[1]++;
      }
    } else if (op == 2) {
      if (isalpha(s[i])) {
        cnt[2]++;
      } else {
        ans += 1ll * cnt[0] * cnt[2];
        if (s[i] == '_' || isdigit(s[i])) {
          cnt[0] = cnt[2];
          op = 0;
        } else if (s[i] == '@') {
          cnt[0] = cnt[2];
          cnt[1] = cnt[2] = 0;
          mid_flag = false;
          op = 1;
        } else {
          cnt[0] = cnt[1] = cnt[2] = 0;
          op = 0;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
