#include <bits/stdc++.h>
using namespace std;
string s;
int N;
vector<int> ma, dot, und, let, dig;
int pre[(1 << 20)];
long long ans = 0;
int main() {
  cin >> s;
  N = s.length();
  int i, j, k, l, u;
  vector<int>::iterator it;
  for (i = 0; i < N; ++i) {
    if (s[i] == '@')
      ma.push_back(i);
    else if (s[i] == '.')
      dot.push_back(i);
    else if (s[i] == '_')
      und.push_back(i);
    else if (s[i] >= 'a' && s[i] <= 'z')
      let.push_back(i);
    else
      dig.push_back(i);
  }
  for (i = 0; i < N; ++i) pre[i] = -1;
  for (i = 0; i < dot.size(); ++i) {
    k = dot[i];
    for (j = k + 1; j < N; ++j) {
      if (s[j] < 'a' || s[j] > 'z') {
        pre[k] = j - 1;
        break;
      }
    }
    if (j == N) pre[k] = N - 1;
    if (pre[k] == k) pre[k] = -1;
  }
  for (i = 0; i < N; ++i) {
    if (s[i] < 'a' || s[i] > 'z') continue;
    it = lower_bound(ma.begin(), ma.end(), i);
    if (it == ma.end()) continue;
    k = *it;
    it = lower_bound(dot.begin(), dot.end(), i);
    if (it == dot.end()) continue;
    l = *it;
    if (l < k + 2 || pre[l] == -1) continue;
    it = lower_bound(ma.begin(), ma.end(), k + 1);
    if (it != ma.end()) {
      u = *it;
      if (u < l) continue;
    }
    it = lower_bound(und.begin(), und.end(), k + 1);
    if (it != und.end()) {
      u = *it;
      if (u < l) continue;
    }
    ans += pre[l] - l;
  }
  cout << ans << '\n';
  return 0;
}
