#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  long long int r, i;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long int power(long long int x, long long int y) {
  long long int temp, ty, my;
  long long int mod;
  mod = 1000000007;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  ty = (temp % mod) * (temp % mod);
  if (y % 2 == 0) {
    return ty % mod;
  } else {
    my = (x % mod) * (ty % mod);
    return my % mod;
  }
}
void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) cout << p << " ";
}
long long int mini(long long int a, long long int b) { return a < b ? a : b; }
long long int maxi(long long int a, long long int b) { return a > b ? a : b; }
struct abhi {
  long long int val1;
  long long int val2;
  long long int po;
};
struct abhi brr[1000001];
bool cmp(struct abhi x, struct abhi y) {
  if (x.val1 == y.val1) return x.val2 < y.val2;
  return x.val1 < y.val1;
}
void fastscan(int &number) {
  bool negative = false;
  register int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
long long int ar[501000];
long long int func(string a) {
  long long int cnt = 0;
  long long int ans = 0;
  long long int ko = a.size();
  for (int i = 0; i < ko; i++) {
    if (a[i] == 's') {
      cnt++;
    } else {
      ans = ans + cnt;
    }
  }
  return ans;
}
bool compare(string &a, string &b) {
  string s1 = a + b;
  string s2 = b + a;
  return func(s1) > func(s2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, k, n, q;
  string ans = "";
  cin >> n;
  vector<string> vec;
  string tem;
  for (i = (0); i < (n); i++) {
    cin >> tem;
    vec.push_back(tem);
  }
  sort(vec.begin(), vec.end(), compare);
  for (i = (0); i < (n); i++) {
    ans += vec[i];
  }
  cout << func(ans) << "\n";
  return 0;
}
