#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& t) {
  return in >> t.first >> t.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& t) {
  return out << t.first << " " << t.second << endl;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& t) {
  for (int i = 0; i < t.size(); i++) in >> t[i];
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& t) {
  for (int i = 0; i < t.size(); i++) out << t[i] << " ";
  return out;
}
struct G {
  set<int> to;
  int is = 0;
};
vector<G> g;
int main() {
  string str;
  cin >> str;
  vector<int> v(str.size(), -1);
  int n = str.size();
  int la = -1;
  for (int i = 0; i < n; i++) {
    if (str[i] == '@')
      la = i;
    else if (str[i] == '_')
      la = -1;
    else if (str[i] == '.') {
      if (la != -1 && v[la] == -1 && i != la + 1)
        v[la] = i;
      else
        la = -1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] == -1) continue;
    int l = i - 1, r = v[i] + 1;
    long long sch = 0;
    for (; l >= 0; l--) {
      if (isalpha(str[l])) sch++;
      if (!(isalnum(str[l]) || str[l] == '_')) break;
    }
    l++;
    for (; r < n; r++) {
      if (!isalpha(str[r])) break;
    }
    r--;
    ans += sch * (r - v[i]);
  }
  cout << ans << endl;
  return 0;
}
