#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
inline int add(int a, int b, int mod = 1000000007) {
  return a + b < mod ? a + b : a + b - mod;
}
inline void addBy(int &a, int b, int mod = 1000000007) { a = add(a, b, mod); }
inline int sub(int a, int b, int mod = 1000000007) {
  return a - b < 0 ? a - b + mod : a - b;
}
inline void subBy(int &a, int b, int mod = 1000000007) { a = sub(a, b, mod); }
inline int mul(int a, int b, int mod = 1000000007) {
  return (long long)a * b % mod;
}
inline void mulBy(int &a, int b, int mod = 1000000007) { a = mul(a, b, mod); }
int inverse(int a, int mod = 1000000007) {
  int d = mod, x = 0, s = 1, q, r, t;
  while (a != 0) {
    q = d / a, r = d % a;
    d = a, a = r;
    t = x - q * s, x = s, s = t;
  }
  if (d != 1) return -1;
  return (x + mod) % mod;
}
inline int divide(int a, int b, int mod = 1000000007) {
  return mul(a, inverse(b, mod), mod);
}
long long mul(long long a, long long b, long long mod = 1000000007) {
  long long x = 0, y = a % mod;
  while (b > 0) {
    if (b % 2 == 1) {
      x = x + y;
      if (x >= mod) x -= mod;
    }
    y = y * 2;
    if (y >= mod) y -= mod;
    b /= 2;
  }
  return x % mod;
}
template <class T>
T pow(T a, T b, T c = 1000000007) {
  T x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = mul(x, y, c);
    }
    y = mul(y, y, c);
    b /= 2;
  }
  return x % c;
}
vector<int> factorial(1, 1);
int fact(int n) {
  while (factorial.size() <= n)
    factorial.push_back(mul(factorial.back(), factorial.size()));
  return factorial[n];
}
int choose(int n, int k) {
  if (n < k) return 0;
  return divide(fact(n), mul(fact(k), fact(n - k)));
}
char s[1000001];
int main() {
  scanf("%s", s);
  int L = strlen(s);
  long long ans = 0;
  for (int i = 0; i < (L); i++) {
    if (s[i] == '@') {
      int left = 0;
      int j = i - 1;
      while (j >= 0 && (isalnum(s[j]) || s[j] == '_')) {
        if (isalpha(s[j])) left++;
        j--;
      }
      j = i + 1;
      int dot = 0, right = 0, letter = 0;
      while (j < L) {
        if (dot == 0) {
          if (s[j] == '.') {
            if (letter)
              dot = 1;
            else
              break;
          } else if (!isalnum(s[j]))
            break;
          else
            letter++;
        } else if (dot == 1) {
          if (!isalpha(s[j])) break;
          right++;
        }
        j++;
      }
      ans += (long long)left * right;
    }
  }
  cout << ans << endl;
  return 0;
}
