#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int add[MAXN], dom[MAXN];
string s;
bool isLetter(char c) { return (c >= 'a' && c <= 'z'); }
bool isNumber(char c) { return (c >= '0' && c <= '9'); }
bool isInName(char c) { return (c == '_' || isLetter(c) || isNumber(c)); }
bool isInAddress(char c) { return (isLetter(c) || isNumber(c)); }
bool isDomain(char c) { return isLetter(c); }
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  add[n - 1] = (isInAddress(s[n - 1]) ? n : n - 1);
  dom[n - 1] = (isDomain(s[n - 1]) ? n : n - 1);
  for (int i = n - 2; i >= 0; i--) {
    if (isInAddress(s[i]))
      add[i] = add[i + 1];
    else
      add[i] = i;
    if (isDomain(s[i]))
      dom[i] = dom[i + 1];
    else
      dom[i] = i;
  }
  long long ans = 0;
  int dot = 0, cur = 0;
  for (int i = 0; i < n; i++) {
    if (isLetter(s[i])) cur++;
    if (s[i] == '@') {
      dot = max(i + 2, dot);
      while (dot < n - 1 && s[dot] != '.') dot++;
      if (dot > n - 2) break;
      if (i + 1 < n && add[i + 1] == dot && dom[dot + 1] > dot + 1)
        ans += (long long)cur * (dom[dot + 1] - (dot + 1));
    }
    if (!isInName(s[i])) cur = 0;
  }
  cout << ans << endl;
  return 0;
}
