#include <bits/stdc++.h>
using namespace std;
string s;
int x[5][1000005];
int main(void) {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  int n = s.size();
  x[0][n] = -1;
  for (int i = n - 1; i >= 0; i--) {
    x[0][i] = x[0][i + 1];
    if (s[i] == '.') x[0][i] = i;
    if (isalnum(s[i])) {
      x[3][i] = 1;
      x[3][i] += x[3][i + 1];
    } else
      x[3][i] = 0;
    if (isalpha(s[i])) {
      x[4][i] = 1;
      x[4][i] += x[4][i + 1];
    } else
      x[4][i] = 0;
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (isalpha(s[i])) x[1][i] = 1;
    if (i) x[1][i] += x[1][i - 1];
    if (isalnum(s[i]) || s[i] == '_') {
      x[2][i] = 1;
      if (i) x[2][i] += x[2][i - 1];
    } else
      x[2][i] = 0;
  }
  long long artem = 0;
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (s[i] == '@') {
      int nxt = x[0][i];
      if (nxt == -1 || nxt == i + 1) continue;
      if (!i) continue;
      int prv = x[2][i - 1];
      int a = x[1][i];
      if (i - prv) a -= x[1][i - prv - 1];
      int b = (x[3][i + 1] == nxt - i - 1);
      int c = x[4][nxt + 1];
      artem += 1LL * a * b * c;
    }
  }
  cout << artem << "\n";
  return 0;
}
