#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
char A[1000005];
vector<int> a, b;
vector<int> nalpha;
int sum[1000005];
int len;
bool ok(int L, int R) {
  int pos = lower_bound(a.begin(), a.end(), L + 1) - a.begin();
  if (pos < a.size() && a[pos] < R) return false;
  return true;
}
int getR(int R) {
  int pos = lower_bound(nalpha.begin(), nalpha.end(), R + 1) - nalpha.begin();
  if (pos < nalpha.size())
    return (nalpha[pos] - 1 - (R + 1) + 1);
  else
    return (len - 1 - (R + 1) + 1);
}
int POS = -1;
int getSum(int l, int r) { return sum[r] - (l - 1 >= 0 ? sum[l - 1] : 0); }
int getL(int L) { return max(0, getSum(POS + 1, L - 1)); }
int main() {
  int i;
  cin >> A;
  len = strlen(A);
  for (i = 0; i < len; i++) {
    if (A[i] == '@' || A[i] == '_' || A[i] == '.') a.push_back(i);
    if (i - 1 >= 0) sum[i] = sum[i - 1];
    if (!isalpha(A[i]))
      nalpha.push_back(i);
    else
      sum[i]++;
  }
  int L = 0, R = 0;
  long long res = 0;
  while (L < len && R < len) {
    while (L < len && A[L] != '@') {
      if (A[L] == '.' || A[L] == '@') POS = L;
      L++;
    }
    while (R < len && R <= L) R++;
    while (R < len && A[R] != '.') R++;
    if (R - L > 1 && ok(L, R)) {
      res += 1ll * getL(L) * max(0, getR(R));
    }
    if (A[L] == '.' || A[L] == '@') POS = L;
    L++;
  }
  cout << res << endl;
}
