#include <bits/stdc++.h>
using namespace std;
int dot[1000006];
int ch[1000006];
int at[1000006];
int under[1000006];
int main() {
  string s;
  ios_base::sync_with_stdio(0);
  ;
  cin >> s;
  long long cnt = 0;
  memset((at), (-1), sizeof(at));
  memset((under), (-1), sizeof(under));
  memset((dot), (-1), sizeof(dot));
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '.') {
      dot[i] = i;
    } else {
      dot[i] = dot[i + 1];
    }
    if (s[i] == '@') {
      at[i] = i;
    } else {
      at[i] = at[i + 1];
    }
    if (s[i] == '_') {
      under[i] = i;
    } else {
      under[i] = under[i + 1];
    }
    if (s[i] >= 'a' && s[i] <= 'z') {
      ch[i] = ch[i + 1] + 1;
    } else {
    }
  }
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      if (dot[i] != -1 && dot[i] < at[i]) continue;
      if (at[i] == -1) continue;
      if (dot[at[i]] == -1) {
        continue;
      }
      if (at[at[i] + 1] != -1 && at[at[i] + 1] < dot[i]) continue;
      if (under[at[i]] != -1 && under[at[i]] < dot[at[i]]) {
        continue;
      }
      if (dot[at[i]] - at[i] == 1) {
        continue;
      }
      int dt = dot[at[i]];
      cnt = cnt + ch[dt + 1];
    }
  }
  cout << cnt << "\n";
  return 0;
}
