#include <bits/stdc++.h>
using namespace std;
vector<int> sieve(long long n) {
  vector<bool> prime(n + 1, true);
  for (int p = 2; p * p <= n; p++)
    if (prime[p] == true)
      for (int i = p * p; i <= n; i += p) prime[i] = false;
  vector<int> v;
  for (int p = 2; p <= n; p++)
    if (prime[p]) v.push_back(p);
  return v;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
string d2b(int i) {
  long long k = 2;
  string bin;
  while (i > 0) {
    if (i % k == 0)
      bin.push_back('0');
    else
      bin.push_back('1');
    i = i / k;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
bool isD4(string bin, string s, int n) {
  long long sum = 0;
  string final;
  reverse((bin).begin(), (bin).end());
  for (int i = 0; i < n; i++) {
    if (bin[i] == '1') {
      final.push_back(s[i]);
    }
  }
  cout << final << '\n';
  if ((stoi(final) - 48) % 4 == 0) return true;
  return false;
}
void solve() {
  string s;
  cin >> s;
  int n = ((int)(s).size());
  long long count = 0;
  for (int i = 0; i < n; i++)
    if ((int(s[i]) - 48) % 4 == 0) count += 1;
  for (int i = 0; i < n - 1; i++) {
    int j = i + 1;
    string final;
    final.push_back(s[i]);
    final.push_back(s[j]);
    long long temp = stoi(final);
    if (temp % 4 == 0) count += (i + 1);
  }
  cout << count << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
