#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
struct stu {
  int type, len;
} a[1001000];
int work(char ch) {
  char ss = ch;
  if (ss == '@') return 1;
  if (ss == '.') return 2;
  if (ss == '_') return 3;
  if (ss >= '0' && ss <= '9') return 4;
  return 5;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  int l = s.length();
  a[0].type = work(s[0]);
  a[0].len = 1;
  int tot = 1;
  for (int i = 1; i < l; i++) {
    int x = work(s[i]);
    if (x == a[tot - 1].type) {
      a[tot - 1].len++;
    } else {
      a[tot].len = 1;
      a[tot].type = x;
      tot++;
    }
  }
  int tl = 0;
  int now = 0;
  long long ans = 0;
  while (now < tot) {
    while (now < tot && a[now].type != 1) {
      if (a[now].type == 2) break;
      if (a[now].type == 5) tl += a[now].len;
      now++;
    }
    if (now >= tot) break;
    if (a[now].type == 2) {
      tl = 0;
      now++;
      continue;
    }
    if (a[now].type == 1 && a[now].len != 1) {
      tl = 0;
      now++;
      continue;
    }
    int bo = 1;
    now++;
    int ttl = 0;
    while (now < tot && a[now].type != 2) {
      if (a[now].type != 5 && a[now].type != 4) {
        bo = 0;
      }
      if (a[now].type == 5) ttl += a[now].len;
      if (a[now].type == 1) break;
      now++;
    }
    if (now >= tot) break;
    if (a[now].type == 1) {
      tl = ttl;
      continue;
    }
    if (bo == 0) {
      tl = 0;
      continue;
    }
    if (a[now].type == 2 && a[now].len != 1) {
      tl = 0;
      now++;
      continue;
    }
    if (a[now].type == 2 && a[now - 1].type == 1) {
      tl = 0;
      now++;
      continue;
    }
    now++;
    if (now < tot && a[now].type == 5) {
      long long tr = a[now].len;
      ans += tr * tl;
    }
    tl = 0;
  }
  cout << ans << endl;
  return 0;
}
