#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T _sq(T a) {
  return a * a;
}
template <class T>
inline T _sqrt(T a) {
  return (T)sqrt((double)a);
}
template <class T, class X>
inline T _pow(T a, X y) {
  T z = 1;
  for (int i = 1; i <= y; i++) {
    z *= a;
  }
  return z;
}
template <class T>
inline T _gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  if (!b) return a;
  return _gcd(b, a % b);
}
template <class T>
inline T _lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / _gcd(a, b)) * b;
}
template <class T>
inline T _extended(T a, T b, T &x, T &y) {
  a = abs(a);
  b = abs(b);
  T g, x1, y1;
  if (!b) {
    x = 1;
    y = 0;
    g = a;
    return g;
  }
  g = _extended(b, a % b, x1, y1);
  x = y1;
  y = x1 - (a / b) * y1;
  return g;
}
template <class T, class X>
inline bool getbit(T a, X i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class X>
inline T setbit(T a, X i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class X>
inline T resetbit(T a, X i) {
  T t = 1;
  return (a & (~(t << i)));
}
template <class T, class X>
inline T togglebit(T a, X i) {
  T t = 1;
  return (a ^ (t << i));
}
template <class T>
void pv(T v) {
  for (int i = 0; i < ((int)v.size()); i++) cout << v[i] << " ";
  cout << endl;
}
template <class T, class X>
inline T _bigmod(T n, X m) {
  unsigned long long ret = 1, a = n % 1000000007;
  while (m) {
    if (m & 1) ret = (ret * a) % 1000000007;
    m >>= 1;
    a = (a * a) % 1000000007;
  }
  ret %= 1000000007;
  return (T)ret;
}
template <class T>
inline T _modinv(T n) {
  return _bigmod(n, 1000000007 - 2);
}
int n, fst[(1000000 + 3)], lst[(1000000 + 3)], dot[(1000000 + 3)],
    numa[(1000000 + 3)], numn[(1000000 + 3)];
string s, r;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  int p = -2000000000, pp = -2000000000;
  for (int i = 0; i < ((int)s.size()); i++) {
    numa[i + 1] = numa[i];
    numn[i + 1] = numn[i];
    if (isalpha(s[i]))
      numa[i + 1]++;
    else if (isdigit(s[i]))
      numn[i + 1]++;
    fst[i + 1] = p;
    if (s[i] == '@' || s[i] == '.')
      p = -2000000000;
    else if (p == -2000000000 && isalpha(s[i]))
      p = i + 1;
  }
  p = pp = 2000000000;
  for (int i = ((int)s.size()) - 1; i >= 0; i--) {
    dot[i + 1] = p;
    if (s[i] == '.') p = i + 1;
    lst[i + 1] = pp;
    if (!isalpha(s[i]))
      pp = 2000000000;
    else if (pp == 2000000000 && isalpha(s[i]))
      pp = i + 1;
  }
  long long ans = 0;
  for (int i = 1; i <= ((int)s.size()); i++) {
    if (s[i - 1] != '@' || fst[i] == -2000000000 || dot[i] == 2000000000 ||
        lst[dot[i]] == 2000000000 || i - fst[i] < 1 || dot[i] - i - 1 < 1 ||
        lst[dot[i]] - dot[i] < 1)
      continue;
    if (numa[dot[i] - 1] - numa[i] + numn[dot[i] - 1] - numn[i] !=
        dot[i] - i - 1)
      continue;
    ans += (long long)(numa[i - 1] - numa[fst[i] - 1]) *
           (long long)(lst[dot[i]] - dot[i]);
  }
  cout << ans << endl;
  return 0;
}
