#include <bits/stdc++.h>
using namespace std;
const long long mod7 = 1000000007;
long long cnt1[1000001];
long long cnt2[1000001];
bool goods(char c) {
  return c == '_' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
         c >= '0' && c <= '9';
}
bool starts(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }
bool goods2(char c) {
  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
         c >= '0' && c <= '9' || c == '.';
}
int main() {
  int n, m;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    if (goods(s[i])) {
      if (starts(s[i])) {
        cnt1[i] = i ? cnt1[i - 1] + 1 : 1;
      } else {
        cnt1[i] = i ? cnt1[i - 1] : 0;
      }
    } else {
      cnt1[i] = 0;
    }
  }
  int temp = 0;
  int last = 0;
  for (int i = s.length() - 1; i >= 0; --i) {
    if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {
      ++temp;
      cnt2[i] = last;
    } else if (s[i] == '.') {
      last = temp;
      temp = 0;
    } else if (s[i] >= '0' && s[i] <= '9') {
      cnt2[i] = last;
      temp = 0;
    } else {
      last = temp = 0;
    }
  }
  long long ans = 0;
  for (int i = 1; i + 1 < s.length(); ++i) {
    if (s[i] == '@') {
      ans += 1ll * cnt1[i - 1] * cnt2[i + 1];
    }
  }
  cout << ans;
  return 0;
}
