#include <bits/stdc++.h>
using namespace std;
char s[1111111];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int i = 0, j = 0;
  long long ans = 0;
  while (i < n && j < n) {
    while (i < n && s[i] != '@') i++;
    if (!(j < n && s[j] == '.' && i < j))
      while (j < n && (j <= i || s[j] != '.')) j++;
    if (i >= n || j >= n) break;
    int good = 1;
    int cnt = 0;
    for (int k = i + 1; k < j; k++)
      if (s[k] == '@' || s[k] == '.' || s[k] == '_') {
        good = 0;
        break;
      } else
        cnt++;
    if (cnt > 0 and good == 1) {
      long long a = 0, b = 0;
      int l = j + 1;
      while (l < n) {
        if (s[l] >= 'a' && s[l] <= 'z')
          b++;
        else
          break;
        l++;
      }
      int k = i - 1;
      while (k >= 0) {
        if (s[k] >= 'a' && s[k] <= 'z') a++;
        if (s[k] == '.' || s[k] == '@') break;
        k--;
      }
      ans += a * b;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}
