#include <bits/stdc++.h>
using namespace std;
int a[1000001];
int b[1000001];
int c[1000001];
int main() {
  string s;
  ios_base::sync_with_stdio(false);
  cin >> s;
  a[0] = b[0] = c[0] = 0;
  if (s[0] >= 'a' && s[0] <= 'z') {
    a[0] = 1;
  }
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      a[i] = a[i - 1] + 1;
      if (b[i - 1]) b[i] = b[i - 1];
      if (c[i - 1]) c[i] = c[i - 1];
    } else if (s[i] >= '0' && s[i] <= '9') {
      a[i] = a[i - 1];
      if (b[i - 1]) b[i] = b[i - 1];
      c[i] = 0;
    } else if (s[i] == '_') {
      a[i] = a[i - 1];
      b[i] = 0;
      c[i] = 0;
    } else if (s[i] == '@') {
      a[i] = 0;
      b[i] = 0;
      c[i] = 0;
      b[i + 1] = a[i - 1];
    } else if (s[i] == '.') {
      a[i] = 0;
      b[i] = 0;
      c[i] = 0;
      c[i + 1] = b[i - 1];
    }
  }
  long long ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    ans += c[i];
  }
  cout << ans << endl;
  return 0;
}
