#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000007;
long long d[3][MAXN], ans = 0;
int main() {
  string s;
  getline(cin, s);
  int lcat = -1, lpoint = -1;
  for (int i = 0; i < s.length(); ++i) {
    if (isalpha(s[i])) {
      ++d[0][i];
    }
    if ((isalpha(s[i]) || isdigit(s[i]) || s[i] == '_') && i) {
      d[0][i] += d[0][i - 1];
    }
    if ((isalpha(s[i]) || isdigit(s[i])) && lcat > 0) {
      d[1][i] += d[0][lcat - 1];
    } else {
      lcat = -1;
    }
    if (isalpha(s[i]) && lpoint > 0) {
      d[2][i] += d[1][lpoint - 1];
    } else {
      lpoint = -1;
    }
    if (s[i] == '.') lpoint = i;
    if (s[i] == '@') lcat = i;
  }
  for (int i = 0; i < s.length(); ++i) ans += d[2][i];
  cout << ans << endl;
  return 0;
}
