#include <bits/stdc++.h>
using namespace std;
long long MOD = (1e9) + 7;
const long long N = 200005;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1;
  for (long long ti = 1; ti <= tc; ti++) {
    string s;
    cin >> s;
    long long n = s.length();
    long long ans = 0;
    long long pre[n], suf[n];
    for (long long i = 0; i < n; i++) pre[i] = (s[i] >= 'a' && s[i] <= 'z');
    for (long long i = 1; i < n; i++) {
      if (s[i] == '@' || s[i] == '.')
        pre[i] = 0;
      else
        pre[i] += pre[i - 1];
    }
    for (long long i = 0; i < n; i++) suf[i] = (s[i] >= 'a' && s[i] <= 'z');
    for (long long i = n - 2; i >= 0; i--) {
      if (s[i] < 'a' || s[i] > 'z')
        suf[i] = 0;
      else
        suf[i] += suf[i + 1];
    }
    for (long long i = 0; i < n; i++) {
      if (s[i] != '@') continue;
      long long j = i + 1;
      while (j < n &&
             ((s[j] >= 'a' && s[j] <= 'z') || (s[j] >= '0' && s[j] <= '9')))
        j++;
      if (j > i + 1 && j < n && s[j] == '.')
        ans += (i ? pre[i - 1] : 0) * (j + 1 < n ? suf[j + 1] : 0);
      i = j - 1;
    }
    cout << ans << endl;
  }
  return 0;
}
