#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int level[1005];
queue<int> pos;
vector<int> adj[1005];
pii bfs(int S)
{
	int las=S;
	vector<int> lis;
	pos.push(S);
	level[S]=0;
	int mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();

			lis.pb(u);
			pos.pop();
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	for(int a=0;a<lis.size();a++)
	{
		int u=lis[a];
		level[u]=-1;
	}
	pos.push(lis.back());
	level[lis.back()]=0;
	mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	for(int a=0;a<lis.size();a++)
	{
		int u=lis[a];
		if(level[u]==mov/2) return pii(u, mov);
	}
	return pii(0, 0);
}

int find_dia(int S)
{
	int las=S;
	int mov=0;
	memset(level, -1, sizeof(level));
	level[S]=0;
	pos.push(S);
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			las=u;
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	pos.push(las);
	memset(level, -1, sizeof(level));
	level[las]=0;
	mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			las=u;
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	return mov-1;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int a=0;a<m;a++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		adj[l].push_back(r);
		adj[r].push_back(l);
	}
	memset(level, -1, sizeof(level));
	vector<pii> dj;
	for(int a=1;a<=n;a++)
	{
		if(level[a]==-1)
		{
			dj.push_back(bfs(a));
		}
	}
	int ix=0;
	for(int a=1;a<dj.size();a++)
	{
		if(dj[a].second > dj[ix].second)
		{
			ix=a;
		}
	}
	vector<pii> edlis;
	for(int a=1;a<dj.size();a++)
	{
		if(a==ix) continue;
		edlis.pb(pii(dj[a].fi, dj[ix].fi));
		adj[dj[a].fi].pb(dj[ix].fi);
		adj[dj[ix].fi].pb(dj[a].fi);
	}
	printf("%d\n", find_dia(1));
	for(int z=0;z<edlis.size();z++)
	{
		printf("%d %d\n", edlis[z].fi, edlis[z].se);
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int level[1005];
queue<int> pos;
vector<int> adj[1005];
pii bfs(int S)
{
	int las=S;
	vector<int> lis;
	pos.push(S);
	level[S]=0;
	int mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();

			lis.pb(u);
			pos.pop();
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	for(int a=0;a<lis.size();a++)
	{
		int u=lis[a];
		level[u]=-1;
	}
	pos.push(lis.back());
	level[lis.back()]=0;
	mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	for(int a=0;a<lis.size();a++)
	{
		int u=lis[a];
		if(level[u]==mov/2) return pii(u, mov);
	}
	return pii(0, 0);
}

int find_dia(int S)
{
	int las=S;
	int mov=0;
	memset(level, -1, sizeof(level));
	level[S]=0;
	pos.push(S);
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			las=u;
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	pos.push(las);
	memset(level, -1, sizeof(level));
	level[las]=0;
	mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			las=u;
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	return mov-1;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int a=0;a<m;a++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		adj[l].push_back(r);
		adj[r].push_back(l);
	}
	for(int a=1;a<=n;a++) sort(adj[a].begin(), adj[a].end());
	memset(level, -1, sizeof(level));
	vector<pii> dj;
	for(int a=1;a<=n;a++)
	{
		if(level[a]==-1)
		{
			dj.push_back(bfs(a));
		}
	}
	int ix=0;
	for(int a=1;a<dj.size();a++)
	{
		if(dj[a].second > dj[ix].second)
		{
			ix=a;
		}
	}
	vector<pii> edlis;
	for(int a=0;a<dj.size();a++)
	{
		if(a==ix) continue;
		edlis.pb(pii(dj[a].fi, dj[ix].fi));
		adj[dj[a].fi].pb(dj[ix].fi);
		adj[dj[ix].fi].pb(dj[a].fi);
	}
	printf("%d\n", find_dia(1));
	for(int z=0;z<edlis.size();z++)
	{
		printf("%d %d\n", edlis[z].fi, edlis[z].se);
	}
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int level[1005];
queue<int> pos;
vector<int> adj[1005];
pii bfs(int S)
{
	int las=S;
	vector<int> lis;
	pos.push(S);
	level[S]=0;
	int mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			lis.pb(u);
			pos.pop();
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	for(int a=0;a<lis.size();a++)
	{
		int u=lis[a];
		level[u]=-1;
	}
	pos.push(lis.back());
	level[lis.back()]=0;
	mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	sort(lis.begin(), lis.end());
	for(int a=0;a<lis.size();a++)
	{
		int u=lis[a];
		if(level[u]==mov/2) return pii(u, mov);
	}
	return pii(0, 0);
}

int find_dia(int S)
{
	int las=S;
	int mov=0;
	memset(level, -1, sizeof(level));
	level[S]=0;
	pos.push(S);
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			las=u;
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	pos.push(las);
	memset(level, -1, sizeof(level));
	level[las]=0;
	mov=0;
	while(!pos.empty())
	{
		int p=pos.size();
		for(int x=0;x<p;x++)
		{
			int u=pos.front();
			pos.pop();
			las=u;
			for(int z=0;z<adj[u].size();z++)
			{
				int v=adj[u][z];
				if(level[v]==-1)
				{
					level[v]=mov+1;
					pos.push(v);
				}
			}
		}
		mov++;
	}
	return mov-1;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int a=0;a<m;a++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		adj[l].push_back(r);
		adj[r].push_back(l);
	}
	for(int a=1;a<=n;a++) sort(adj[a].begin(), adj[a].end());
	memset(level, -1, sizeof(level));
	vector<pii> dj;
	for(int a=1;a<=n;a++)
	{
		if(level[a]==-1)
		{
			dj.push_back(bfs(a));
		}
	}
	int ix=0;
	for(int a=1;a<dj.size();a++)
	{
		if(dj[a].second > dj[ix].second)
		{
			ix=a;
		}
	}
	vector<pii> edlis;
	for(int a=0;a<dj.size();a++)
	{
		if(a==ix) continue;
		edlis.pb(pii(dj[a].fi, dj[ix].fi));
		adj[dj[a].fi].pb(dj[ix].fi);
		adj[dj[ix].fi].pb(dj[a].fi);
	}
	printf("%d\n", find_dia(1));
	for(int z=0;z<edlis.size();z++)
	{
		printf("%d %d\n", edlis[z].fi, edlis[z].se);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define INF 1000000007
#define mod 998244353
#define INF64 1e18

/*ll power(ll a,ll b){
  ll res=1;
  while(b>0){
    if(b&1)(res*=a)%=mod;
    (a*=a)%=mod;
    b>>=1;
  }
  return res;
}*/

void solve(){
  int n ;string s;
  cin>>s;
  n=s.size();
  int a=0,x;
  for(int i=0;i<n;i++){
    if(s[i]=='0'||s[i]=='4'||s[i]=='8')a++;
    if(i){
      x=(s[i-1]-'0')*10+s[i]-'0';
      if(x%4==0)
        a=(a+i)%INF;
    }
  }
  cout<<a;

}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int T;
  //cin>>T;
  T=1;
  while(T--){
    solve();
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define INF 1000000007
#define mod 998244353
#define INF64 1e18

/*ll power(ll a,ll b){
  ll res=1;
  while(b>0){
    if(b&1)(res*=a)%=mod;
    (a*=a)%=mod;
    b>>=1;
  }
  return res;
}*/

void solve(){
  int n ;string s;
  cin>>s;
  n=s.size();
  int a=0,x;
  for(int i=0;i<n;i++){
    if((s[i]-'0')%4==0)a++;
    if(i){
      x=(s[i-1]-'0')*10+s[i]-'0';
      if(x%4==0)
        a=(a+i)%INF;
    }
  }
  cout<<a;

}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int T;
  //cin>>T;
  T=1;
  while(T--){
    solve();
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define INF 1000000007
#define mod 998244353
#define INF64 1e18

/*ll power(ll a,ll b){
  ll res=1;
  while(b>0){
    if(b&1)(res*=a)%=mod;
    (a*=a)%=mod;
    b>>=1;
  }
  return res;
}*/

void solve(){
  int n ;string s;
  cin>>s;
  n=s.size();
  int a=0,x;
  for(int i=0;i<n;i++){
    if(s[i]=='0'||s[i]=='4'||s[i]=='8')a++;
    if(i){
      x=(s[i-1]-'0')*10+s[i]-'0';
      if(x%4==0)
        a=(a+i);
    }
  }
  cout<<a;

}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int T;
  //cin>>T;
  T=1;
  while(T--){
    solve();
  }
}


#include <iostream>
#include <string>

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    string s;
    cin >> s;
    ll ans = 0;
    for (ll i = s.size() - 1;i >= 2;i--){
        ll a = stoi(s.substr(i-1,2));
//        cout << "a: " << a << endl;
        if (a % 4 == 0){
            ans += (i);
        }
//        cout << ans << endl;
    }
    if (s.size() > 1) {
        if (stoi(s.substr(0, 2)) % 4 == 0) {
            ans++;
        }
    }
    for (int i = 0;i < s.size();i++){
        if (stoi(s.substr(i,1)) % 4 == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = s.size() - 1;i >= 2;i--){
        int a = stoi(s.substr(i-1,2));
//        cout << "a: " << a << endl;
        if (a % 4 == 0){
            ans += (i);
        }
//        cout << ans << endl;
    }
    if (stoi(s.substr(0,2)) % 4 == 0){
        ans++;
    }
    for (int i = 0;i < s.size();i++){
        if (stoi(s.substr(i,1)) % 4 == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2")
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <numeric>
#include <fstream>

using std::cin;
using std::cout;
using std::vector;
using ll = long long;
using pii = std::pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
#define all(x) (x).begin(), (x).end()
#define forx(x, n) for(int x = 0; x < n; ++x)
#define for1(x, n) for(int x = 1; x < n; ++x)
#define range(x, a, b) for(int x = a; x <= b; ++x)

template<class T>
std::istream& operator>>(std::istream &reader, std::vector<T>& v)
{
	for (auto &item : v) reader >> item;
	return reader;
}

template<class T>
std::ostream& operator<<(std::ostream &writer, std::vector<T>& v)
{
	for (auto &item : v) writer << item << " ";
	return writer;
}

template<class A, class B>
void remax(A &a, B &b)
{
	a = (a > b) ? a : b;
}

template<class A, class B>
void remin(A &a, B &b)
{
	a = (a < b) ? a : b;
}

const auto ready = []()
{
	cin.tie(0);
	cout.tie(0);
	std::ios_base::sync_with_stdio(false);
	return true;
}();

ll fast_multip(ll a, ll b, ll m)
{
	if (!a || !b) return 0;
	if (b == 1) return a;
	if (a == 1) return b;
	if (b % 2 == 0) {
		long long t = fast_multip(a, b / 2, m);
		return (2 * t) % m;
	}
	return (fast_multip(a, b - 1, m) + a) % m;
}

ll fast_pow(ll a, ll b, ll m)
{
	if (b == 0)
		return (m == 1) ? 0 : 1;
	if (b % 2 == 0) {
		ll t = fast_pow(a, b / 2, m);
		return fast_multip(t, t, m) % m;
	}
	return (fast_multip(fast_pow(a, b - 1, m), a, m)) % m;
}

struct segTree
{
	int n;
	vector<vpii> data;

	void build(vi& vec)
	{
		n = vec.size();
		data.resize(4 * n);
		init(0, 0, n - 1, vec);
	}

	void init(int v, int l, int r, vi& vec)
	{
		if (l == r) data[v].push_back({ vec[l], l });
		else
		{
			int m = l + r >> 1;
			init(2 * v + 1, l, m, vec);
			init(2 * v + 2, m + 1, r, vec);
			for (auto &x : data[2 * v + 1]) data[v].push_back(x);
			for (auto &x : data[2 * v + 2]) data[v].push_back(x);
			std::sort(all(data[v]));
		}
	}

	int get(int v, int l, int r, int ql, int qr, int x)
	{
		if (ql == l && qr == r)
		{
			if (l == r) return (data[v][0].first == x) ? -2 : data[v][0].second;
			int kek1 = data[v][0].first;
			int kek2 = data[v].back().first;
			if (kek1 != x) return data[v][0].second;
			if (kek2 != x) return data[v].back().second;
			return -2;
		}
		else
		{
			int m = l + r >> 1;
			int ans = -2;
			if (ql <= m)
			{
				int kek1 = get(2 * v + 1, l, m, ql, std::min(m, qr), x);
				if (kek1 > ans) ans = kek1;
			}
			if (qr > m)
			{
				int kek2 = get(2 * v + 2, m + 1, r, std::max(m + 1, ql), qr, x);
				if (kek2 > ans) ans = kek2;
			}
			return ans;
		}
	}
};

int main()
{
	std::string s; cin >> s;
	ll ans = 0;
	int n = s.size();
	if (n == 1)
	{
		cout << ((s[0] == '4') ? 1 : 0) << "\n";
	}
	else
	{
		for (int i = n - 2; i >= 0; --i)
		{
			std::string cur = s.substr(i, 2);
			if (std::stoi(cur) % 4 == 0) ans += (i + 1);
		}
		for (int i = 0; i < n; ++i) if (std::stoi(s.substr(i, 1)) % 4 == 0) ++ans;
		cout << ans << "\n";
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mset(a, val) memset(a, val, sizeof(a));
#define TC int t; cin >> t; while(t--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

int main(){
    fastio
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

    string s;
    cin >> s;

    int n = s.length();
    int a = 0, b = 0;
    for (int i = 0; i < n ;i++){
        if(i<n-1){
            if(stoi(s.substr(i, 2)) %4 == 0 ){
                a += (i + 1);
            }
        }
        if((s[i] - '0') == 0 || (s[i] - '0')  == 4 || (s[i] - '0') == 8){
            b++;
        }

    }
    cout << a +b;
#ifndef ONLINE_JUDGE
		cerr<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << " ms." << endl;
#endif
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mset(a, val) memset(a, val, sizeof(a));
#define TC int t; cin >> t; while(t--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

int main(){
    fastio
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

    string s;
    cin >> s;

    int n = s.length();
    int a = 0, b = 0;
    for (int i = 0; i < n ;i++){
        if(i<n-1){
            if(stoi(s.substr(i, 2)) %4 == 0 ){
                a += (i + 1);
            }
        }
        if((s[i] - '0') == 0 || (s[i] - '0')  == 4 || (s[i] - '0') == 8){
            b++;
        }
    }
    cout << a +b;
#ifndef ONLINE_JUDGE
		cerr<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << " ms." << endl;
#endif
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mset(a, val) memset(a, val, sizeof(a));
#define TC int t; cin >> t; while(t--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

int main(){
    fastio
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

    string s;
    cin >> s;

    int n = s.length();
    ll a = 0LL, b = 0LL;
    for (int i = 0; i < n ;i++){
        if(i<n-1){
            if(stoi(s.substr(i, 2)) %4 == 0 ){
                a += (i + 1);
            }
        }
        if((s[i] - '0') == 0 || (s[i] - '0')  == 4 || (s[i] - '0') == 8){
            b++;
        }
    }
    cout << a +b;
#ifndef ONLINE_JUDGE
		cerr<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << " ms." << endl;
#endif
	return 0;
}


#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <unordered_map>
#include <algorithm>

int main() {
  std::string input;
  std::cin >> input;
  unsigned long size = input.size();
  std::vector<std::vector<int>> reminders(size, std::vector<int>(size));
  long long result = 0;
  for (int pos = 0; pos < size; pos++) {
    reminders[pos][pos] = (input[pos] - '0') % 4;
    if (!reminders[pos][pos]) {
      result++;
    }
  }
  for (int start = 0; start < size; start++) {
    for (int end = start + 1; end < size; end++) {
      reminders[start][end] = (reminders[start][end - 1] * 10 + (input[end] - '0')) % 4;
      if (!reminders[start][end]) {
        result++;
      }
    }
  }
  std::cout << result;
  return 0;
}


#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <unordered_map>
#include <algorithm>

int main() {
  std::string input;
  std::cin >> input;
  unsigned long size = input.size();
  long long result = 0;
  for (int start = 0; start < size; start++) {
    int reminder = (input[start] - '0') % 4;
    if (!reminder) result++;
    for (int end = start + 1; end < size; end++) {
      reminder = ((reminder * 10) + (input[end] - '0')) % 4;
      if (!reminder) result++;
    }
  }
  std::cout << result;
  return 0;
}


#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <unordered_map>
#include <algorithm>

int main() {
  std::string input;
  std::cin >> input;
  unsigned long size = input.size();
  long long result = 0;
  std::vector<int> reminders(4);
  for (int start = 0; start < size; start++) {
    std::vector<int> copy(4);
    for (int i = 0; i < 4; i++) {
      int i1 = i * 10 + (input[start] - '0');
      copy[i1 % 4] += reminders[i];
    }
    copy[(input[start] - '0') % 4]++;
    result += copy[0];
    reminders = copy;
  }
  std::cout << result;
  return 0;
}


// https://codeforces.com/contest/628/problem/B
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >>s;
    int answer=0;
    for(int i = 0 ; i < s.length() ;i++){
        for(int j = 1 ; j <= s.length()-i;j++){
            string temp=s.substr(i,j);

            if(temp.length()>2){

                if(stoi(temp.substr(temp.length()-2,2))%4==0){

                    answer++;
                }

            }
            else{
                if(stoi(temp)%4==0){

                    answer++;
                }
            }

        }
    }

    cout << answer;
}


// https://codeforces.com/contest/628/problem/B
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >>s;
    int answer=0;
    for(int i = s.length()-1 ; i >0 ;i--){
        string temp = s.substr(i-1,2);
        // cout <<temp << " ";
        if(stoi(temp)%4==0){
            answer+=i;
        }
    }

    for(int i = 0 ; i < s.length();i++){
        if(stoi(s.substr(i,1))%4==0){
            answer++;
        }
    }

    cout << answer;
}


// https://codeforces.com/contest/628/problem/B
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >>s;
    long long answer=0;
    for(int i = s.length()-1 ; i >0 ;i--){
        string temp = s.substr(i-1,2);
        // cout <<temp << " ";
        if(stoi(temp)%4==0){
            answer+=i;
        }
    }

    for(int i = 0 ; i < s.length();i++){
        if(stoi(s.substr(i,1))%4==0){
            answer++;
        }
    }

    cout << answer;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma warning(disable:4996)
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <cstring>
#include <bitset>
#include <time.h>
#include <string>
#include <chrono>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define itn int
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define matrix vector<vector<ll>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define dig(c) (c >=' 0' && c <= '9') ? 1 : 0
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████	█▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--+--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 1000001;
const int inf = 1000000001;
const ld INF = 1.0 / 0.0;
const ld EPS = 1e-7;
const int mod = inf + 6;
const ld PI = acos(-1.0);
signed main()
{
	fastio();
	string s;
	cin >> s;
	vector<int> cnt(4);
	cnt[0] = 1;
	int now = 0;
	ll ans = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		now += s[i] - '0';
		now %= 4;
		ans += cnt[now];
		cnt[now] ++;
	}
	cout << ans;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma warning(disable:4996)
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <cstring>
#include <bitset>
#include <time.h>
#include <string>
#include <chrono>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define itn int
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define matrix vector<vector<ll>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define dig(c) (c >=' 0' && c <= '9') ? 1 : 0
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████	█▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--+--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 1000001;
const int inf = 1000000001;
const ld INF = 1.0 / 0.0;
const ld EPS = 1e-7;
const int mod = inf + 6;
const ld PI = acos(-1.0);
signed main()
{
	fastio();
	string s;
	cin >> s;
	ll ans = ((s[0] - '0') % 4 == 0);
	for (int i = 1; i < s.size(); ++i)
	{
		if ((s[i] - '0') % 4 == 0)
		{
			ans++;
		}
		int num = (s[i - 1] - '0') * 10 + s[i] - '0';
		if (num % 4 == 0)
		{
			ans += i;
		}
	}
	cout << ans;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma warning(disable:4996)
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <cstring>
#include <bitset>
#include <time.h>
#include <string>
#include <chrono>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define itn int
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define matrix vector<vector<ll>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define dig(c) (c >=' 0' && c <= '9') ? 1 : 0
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████	█▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--+--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 1000001;
const int inf = 1000000001;
const ld INF = 1.0 / 0.0;
const ld EPS = 1e-7;
const int mod = inf + 6;
const ld PI = acos(-1.0);
signed main()
{
	fastio();
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 1; i < s.size(); ++i)
	{
		if ((s[i] - '0') % 4 == 0)
		{
			ans++;
		}
		int num = (s[i - 1] - '0') * 10 + s[i] - '0';
		if (num % 4 == 0)
		{
			ans += i;
		}
	}
	cout << ans;
}


#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int i,j,k,n,m,c=0;
	string s;
	cin>>s;
	n=s.length();
	for(i=n-1;i>0;i--)
	{
	    if((s[i]-'0')%4==0)
	        c++;
	    if(((s[i]-'0')+(s[i-1]-'0')*10)%4==0)
	        c+=i;
	}
	if((s[0]-'0')%4==0)
	    c++;
	   cout<<c<<endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long int i,j,k,n,m,c=0;
	string s;
	cin>>s;
	n=s.length();
	for(i=n-1;i>0;i--)
	{
	    if((s[i]-'0')%4==0)
	        c++;
	    if(((s[i]-'0')+(s[i-1]-'0')*10)%4==0)
	        c+=i;
	}
	if((s[0]-'0')%4==0)
	    c++;
	   cout<<c<<endl;
	return 0;
}


#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz size()
#define ll long long
#define ld long double
#define ull unsigned long long
#define r0 return 0
#define y1 yy1
#define _____ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
const int N = 3e5+5;
string s;
int main (){ _____
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.sz; ++i)
		if (s[i] == '4' || s[i] == '8')
			++ans;
	for (int i = s.sz - 1; i > 0; --i)
		if (((int)(s[i] - '0') + (int)(s[i - 1] - '0') * 10) % 4 == 0){
			ans += i + 1;
			break;
		}
	cout << ans;
	r0;
}


#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz size()
#define ll long long
#define ld long double
#define ull unsigned long long
#define r0 return 0
#define y1 yy1
#define _____ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
const int N = 3e5+5;
string s;
int main (){ _____
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.sz; ++i)
		if (s[i] == '0' || s[i] == '4' || s[i] == '8')
			++ans;
	for (int i = s.sz - 1; i > 0; --i)
		if (((int)(s[i] - '0') + (int)(s[i - 1] - '0') * 10) % 4 == 0){
			ans += i;
		}
	cout << ans;
	r0;
}


#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz size()
#define ll long long
#define ld long double
#define ull unsigned long long
#define r0 return 0
#define y1 yy1
#define _____ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
const int N = 3e5+5;
string s;
int main (){ _____
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < s.sz; ++i)
		if (s[i] == '0' || s[i] == '4' || s[i] == '8')
			++ans;
	for (int i = s.sz - 1; i > 0; --i)
		if (((int)(s[i] - '0') + (int)(s[i - 1] - '0') * 10) % 4 == 0){
			ans += i;
		}
	cout << ans;
	r0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long c=0,l,r,d;
    string s;

    cin >> s;
    for(int i=0;i<s.length();i++)
    {
        if((s[i]-'0')%4==0)
            c++;
    }
    l = s.length()-2;
    r = s.length()-1;
    while(l>=0)
    {
       d = ((s[l]-'0')*10) +((s[r]-'0'));
       if(d%4==0)
        c+= (1+l);
       l--;
       r--;
    }
    cout << c;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long int n=s.length();
	long  long int ans,x,y,i;
	for(i=n-1;i>=0;i--)
	{
		x=s[i]-'0';
		if(x%4==1 || x%4==3)
			continue;
		if(x%4==0)
			ans++;
		if(i!=0)
		{
			y=s[i-1]-'0';
			if(x%4==0 && y%2==0) ans+=i;
			if(x%4==2 && y%2==1) ans+=i;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long int n=s.length();
	long long int ans=0,i,x,y;
	for(i=n-1;i>=0;i--)
	{
	    x=s[i]-'0';
		if(x%4==1 || x%4==3)
			continue;
		if(x%4==0)
			ans++;
		if(i!=0)
		{
			y=s[i-1]-'0';
			if(x%4==0 && y%2==0) ans+=i;
			if(x%4==2 && y%2==1) ans+=i;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	int ans,x,y;
	for(int i=n-1;i>=0;i--)
	{
		int x=s[i]-'0';
		if(x%4==1 || x%4==3)
			continue;
		if(x%4==0)
			ans++;
		if(i!=0)
		{
			y=s[i-1]-'0';
			if(x%4==0 && y%2==0) ans+=i;
			if(x%4==2 && y%2==1) ans+=i;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	int ans=0,x,y;
	for(int i=n-1;i>=0;i--)
	{
		int x=s[i]-'0';
		if(x%4==1 || x%4==3)
			continue;
		if(x%4==0)
			ans++;
		if(i!=0)
		{
			y=s[i-1]-'0';
			if(x%4==0 && y%2==0) ans+=i;
			if(x%4==2 && y%2==1) ans+=i;
		}
	}
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mxN = 3e5+1;

int dp[mxN];

void solve() {
    string str;

    cin >> str;

    int n = atoi(str.c_str());

    int s = str.size();

    dp[0] = 0;

    for (int i = 1; i <= s; i++) {
        int newNumsN = 0;
        for (int j = 0; j < i; j++) {
            // int num = atoi(str.substr(j, i - j).c_str());
            int num = (n%int(pow(10, s-j)))/int(pow(10, s-i));
            if (num%4 == 0) newNumsN++;
        }
        dp[i] = dp[i-1] + newNumsN;
    }

    cout << dp[s];

}

int main() {

    // int t;
    // cin >> t;

    // while (t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mxN = 3e5+1;

int dp[mxN];

void solve() {
    string str;

    cin >> str;

    int s = str.size();

    dp[0] = 0;

    for (int i = 1; i <= s; i++) {
        int newNumsN = 0;
        if (i < 2) {
            if ((str[0]-48)%4 == 0) newNumsN++;
        } else {
            int endNum = atoi(str.substr(i-2, 2).c_str());
            if (endNum%4 == 0) newNumsN += i-1;
            if ((str[i-1]-48)%4 == 0) newNumsN++;
        }

        dp[i] = dp[i-1] + newNumsN;
        // cout << dp[i] << "\n";
    }

    cout << dp[s];

}

int main() {

    // int t;
    // cin >> t;

    // while (t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mxN = 3e5+1;

int dp[mxN];

void solve() {
    string str;

    cin >> str;

    int s = str.size();

    dp[0] = 0;

    for (int i = 1; i <= s; i++) {
        int newNumsN = 0;
        if (i < 2) {
            if ((str[0]-48)%4 == 0) newNumsN++;
        } else {
            int endNum = atoi(str.substr(i-2, 2).c_str());
            if (endNum%4 == 0) newNumsN += i-1;
            if ((str[i-1]-48)%4 == 0) newNumsN++;
        }

        dp[i] = dp[i-1] + newNumsN;
        cout << dp[i] << "\n";
    }

    cout << "\n" << dp[s];

}

int main() {

    // int t;
    // cin >> t;

    // while (t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mxN = 3e5+1;

long long dp[mxN];

void solve() {
    string str;

    cin >> str;

    int s = str.size();

    dp[0] = 0;

    for (int i = 1; i <= s; i++) {
        long long newNumsN = 0;
        if (i < 2) {
            if ((str[0]-48)%4 == 0) newNumsN++;
        } else {
            int endNum = atoi(str.substr(i-2, 2).c_str());
            if (endNum%4 == 0) newNumsN += i-1;
            if ((str[i-1]-48)%4 == 0) newNumsN++;
        }

        dp[i] = dp[i-1] + newNumsN;
        // cout << dp[i] << "\n";
    }

    cout << dp[s];

}

int main() {

    // int t;
    // cin >> t;

    // while (t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mxN = 3e5+1;

int dp[mxN];

void solve() {
    string str;

    cin >> str;

    dp[0] = 0;

    for (int i = 1; i <= str.size(); i++) {
        int newNumsN = 0;
        for (int j = 0; j < i; j++) {
            int num = atoi(str.substr(j, i - j).c_str());
            if (num%4 == 0) newNumsN++;
        }
        dp[i] = dp[i-1] + newNumsN;
    }

    cout << dp[str.size()];

}

int main() {

    // int t;
    // cin >> t;

    // while (t--)
        solve();

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define LL long long
using namespace std;char a[100009];
int b[100009];
int main(){
LL sum=0,i,l,j,k,x;
scanf("%s",a);
l=strlen(a);
for (i=0;i<l;i++){
b[i]=a[i]-48;
}
if (b[0]%4==0){sum++;}
for (i=1;i<l;i++){
if (b[i]==4||b[i]==0||b[i]==8){
if ((b[i-1]*10+b[i])%4==0){sum+=i+1;}
else {sum++;}
}
if (b[i]==2||b[i]==6){
if ((b[i-1]*10+b[i])%4==0){sum+=i;}
}

}

printf("%lld",sum);
return 0;

}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define LL long long
using namespace std;
LL h(LL x){
LL i,sum=1;
for (i=0;i<x;i++){
    sum*=10;
}
return sum;
}
int main(){
char a[100009];
LL sum=0,i,l,j,k,x;
scanf("%s",a);
l=strlen(a);
j=0;
while (j<l)
{
for (i=0;i<l-j;i++){x=0;
for (k=i;k<i+j+1;k++){
        x+=(a[k]-48)*h(j-(k-i));

}if (x%4==0){sum++;}
}
j++;
}
printf("%lld",sum);
return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define LL long long
using namespace std;char a[100009];
int b[100009];
int main(){
LL sum=0,i,l,j,k,x;
scanf("%s",a);
l=strlen(a);
for (i=0;i<l;i++){
b[i]=a[i]-48;
}
if (b[0]%4==0){sum++;}
for (i=1;i<l;i++){
if (b[i]==4||b[i]==0||b[i]==8){
if ((b[i-1]*10+b[i])%4==0){sum+=i+1;}
else {sum++;}
}
if (b[i]==2||b[i]==6){
if ((b[i-1]*10+b[i])%4==0){sum+=i;}
}

}

printf("%d",sum);
return 0;

}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define LL long long
using namespace std;
char a[300009];
LL b[300009];
int main(){
LL sum=0,i,l,j,k,x;
scanf("%s",a);
l=strlen(a);
for (i=0;i<l;i++){
b[i]=a[i]-48;
}
if (b[0]%4==0){sum++;}
for (i=1;i<l;i++){
if (b[i]==4||b[i]==0||b[i]==8){
if ((b[i-1]*10+b[i])%4==0){sum+=i+1;}
else {sum++;}
}
if (b[i]==2||b[i]==6){
if ((b[i-1]*10+b[i])%4==0){sum+=i;}
}

}

printf("%lld",sum);
return 0;

}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define LL long long
using namespace std;
char a[100009];
LL b[100009];
int main(){
LL sum=0,i,l,j,k,x;
scanf("%s",a);
l=strlen(a);
for (i=0;i<l;i++){
b[i]=a[i]-48;
}
if (b[0]%4==0){sum++;}
for (i=1;i<l;i++){
if (b[i]==4||b[i]==0||b[i]==8){
if ((b[i-1]*10+b[i])%4==0){sum+=i+1;}
else {sum++;}
}
if (b[i]==2||b[i]==6){
if ((b[i-1]*10+b[i])%4==0){sum+=i;}
}

}

printf("%lld",sum);
return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
//#define max 100005
//bool visited[max];
#define N 100000

int findways(string s){
    int dp[s.size()][s.size()];
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            dp[i][j]=0;
        }
    }
    int n=s.size();
    int count=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-i+1;j++){
            //cout<<i<<" "<<j<<endl;
            int st=j;
            int ed=j+i-1;
            //cout<<st<<" "<<ed<<endl;
            if(st==ed){
                if((s[st]-'0')%4==0){
                    dp[st][ed]=1;
                }
            }
            else{
                int a=s[ed]-'0';
                int b=s[ed-1]-'0';
                int c=b*10 + a;
                int e;
                if(c%4==0){
                    e=1;
                }
                else{
                    e=0;
                }
                dp[st][ed]=dp[st+1][ed]+dp[st][ed-1] + e-dp[st+1][ed-1];
            }
        }
    }
    cout<<dp[0][n-1];
}
signed main()
{
    C
    string s;
    cin>>s;

    findways(s);

}


#include<bits/stdc++.h>
using namespace std;
#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
//#define max 100005
//bool visited[max];
#define N 100000

int findways(string s){
    char dp[s.size()][s.size()];
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            dp[i][j]='0';
        }
    }
    int n=s.size();
    int a,b,c,e;
    ll d;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-i+1;j++){
            //cout<<i<<" "<<j<<endl;
            int st=j;
            int ed=j+i-1;
            //cout<<st<<" "<<ed<<endl;
            if(st==ed){
                if((s[st]-'0')%4==0){
                    dp[st][ed]='1';
                }
            }
            else{
                a=s[ed]-'0';
                b=s[ed-1]-'0';
                c=b*10 + a;
                if(c%4==0){
                    e=1;
                }
                else{
                    e=0;
                }
                d=(dp[st+1][ed]-'0')+(dp[st][ed-1]-'0') + e-(dp[st+1][ed-1]-'0');
                dp[st][ed]=d+'0';
            }
        }
    }
    cout<<(dp[0][n-1]-'0');
}
signed main()
{
    C
    string s;
    cin>>s;
    findways(s);

}


#include<bits/stdc++.h>
using namespace std;
#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
//#define max 100005
//bool visited[max];
#define N 100000

int findways(string s){
    ll n=s.size(),a,b,c,count=0;
    for(ll i=0;i<n-1;i++){
        a=s[i]-'0';
        b=s[i+1]-'0';
        c=a*10 + b;
        if(c%4==0){
            count=count+i+1;
        }
        if(a%4==0){
            count++;
        }
    }
    if((s[n-1]-'0')%4==0){
        count++;
    }
    cout<<count;
}
signed main()
{
    C
    string s;
    cin>>s;
    findways(s);

}


#include<bits/stdc++.h>
using namespace std;
#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
//#define max 100005
//bool visited[max];
#define N 100000

int findways(string s){
    int dp[s.size()][s.size()];
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            dp[i][j]=0;
        }
    }
    int n=s.size();
    int a,b,c,e;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-i+1;j++){
            //cout<<i<<" "<<j<<endl;
            int st=j;
            int ed=j+i-1;
            //cout<<st<<" "<<ed<<endl;
            if(st==ed){
                if((s[st]-'0')%4==0){
                    dp[st][ed]=1;
                }
            }
            else{
                a=s[ed]-'0';
                b=s[ed-1]-'0';
                c=b*10 + a;
                if(c%4==0){
                    e=1;
                }
                else{
                    e=0;
                }
                dp[st][ed]=dp[st+1][ed]+dp[st][ed-1] + e-dp[st+1][ed-1];
            }
        }
    }
    cout<<dp[0][n-1];
}
signed main()
{
    C
    string s;
    cin>>s;
    findways(s);

}


#include<bits/stdc++.h>
using namespace std;
#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
//#define max 100005
//bool visited[max];
#define N 100000

int findways(string s){
    char dp[s.size()][s.size()];
    for(int i=0;i<s.size();i++){
        for(int j=0;j<s.size();j++){
            dp[i][j]='0';
        }
    }
    int n=s.size();
    int a,b,c,e;
    ll d;
    for(int i=1;i<=n;i++){
        for(int j=0;j<n-i+1;j++){
            //cout<<i<<" "<<j<<endl;
            int st=j;
            int ed=j+i-1;
            //cout<<st<<" "<<ed<<endl;
            if(st==ed){
                if((s[st]-'0')%4==0){
                    dp[st][ed]='1';
                }
            }
            else{
                a=s[ed]-'0';
                b=s[ed-1]-'0';
                c=b*10 + a;
                if(c%4==0){
                    e=1;
                }
                else{
                    e=0;
                }
                d=(dp[st+1][ed]-'0')+(dp[st][ed-1]-'0') + e-(dp[st+1][ed-1]-'0');
                dp[st][ed]=d+'0';
            }
        }
    }
    cout<<(dp[0][n-1]-'0');
    return 0;
}
signed main()
{
    C
    string s;
    cin>>s;
    findways(s);

}


#include <bits/stdc++.h>

using namespace std;

int main(){
	string ins, sus;
	cin >> ins;
	int ans=0;
	long long int stoint;
	for(int i = 0; i < ins.size(); i++){
		for(int j = ins.size()-i; j >=1; j--){
			//cout << "seq " <<i << j << endl;
			sus = ins.substr(i,j);
			//cout << sus << endl;
			stoint = stoll(sus);
			if(stoint%4==0) ans++;
		}
	}
	cout << ans << endl;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
	string ins;
	cin >> ins;
	long long int counter = 0;
	for(long long int i = ins.size()-1; i>=0; i--){
		if(ins[i]%4==0) counter++;
		if(i < ins.size()-1){
			if((ins[i]*10+ins[i+1])%4==0) counter+=(i+1);
		}

	}
	cout << counter << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int main(){
	string ins;
	cin >> ins;
	int counter = 0;
	for(int i = ins.size()-1; i>=0; i--){
		if(ins[i]%4==0) counter++;
		if(i < ins.size()-1){
			if((ins[i]*10+ins[i+1])%4==0) counter+=(i+1);
		}

	}
	cout << counter << endl;
	return 0;

}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll inf=INT_MAX;
const int base = 1e9 + 7;
const int maxn = 1e5 + 1;

#define ull unsigned long long
#define int ll
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,a,b) for (int i = a; i > b; --i)
#define REP(i,a,b) for (int i = a; i <= b; ++i)
#define PER(i,a,b) for (int i = a; i >= b; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int n = s.size(), cnt = 0, cnt4 = 0;
    int dp[n+1];
    FOR(i,0,n-1)
    {
        if (((s[i]-'0')*10+s[i+1]-'0')%4==0) cnt+=i+1;
        if ((s[i]-'0')%4==0) cnt4++;
    }
    if ((s[n-1]-'0')%4==0) cnt4++;
    cout << cnt+cnt4;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll inf=INT_MAX;
const int base = 1e9 + 7;
const int maxn = 1e5 + 1;

#define ull unsigned long long
//#define int ll
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,a,b) for (int i = a; i > b; --i)
#define REP(i,a,b) for (int i = a; i <= b; ++i)
#define PER(i,a,b) for (int i = a; i >= b; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int n = s.size(), cnt = 0, cnt4 = 0;
    int dp[n+1];
    FOR(i,0,n-1)
    {
        if (((s[i]-'0')*10+s[i+1]-'0')%4==0) cnt+=i+1;
        if ((s[i]-'0')%4==0) cnt4++;
    }
    if ((s[n-1]-'0')%4==0) cnt4++;
    cout << cnt+cnt4;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll inf=INT_MAX;
const int base = 1e9 + 7;
const int maxn = 1e5 + 1;

#define ull unsigned long long
//#define int ll
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define ROF(i,a,b) for (int i = a; i > b; --i)
#define REP(i,a,b) for (int i = a; i <= b; ++i)
#define PER(i,a,b) for (int i = a; i >= b; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int n = s.size(), cnt = 0, cnt4 = 0;
    int dp[n+1];
    FOR(i,0,n)
    {
        if (((s[i]-'0')*10+s[i+1]-'0')%4==0) cnt+=i;
        if ((s[i]-'0')%4==0) cnt4++;
    }
    cout << cnt+cnt4;
}


#include<bits/stdc++.h>
using namespace std;

#define ll long long
string s1;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll sum=0;

    cin >> s1;

    for(int i=0; s1[i]!=0; i++){

        if((s1[i]-48)%4 == 0){
            sum++;
        }

        if(s1[i+1] == 0) break;

        ll a,b,c;
        a = s1[i]-48;
        b = s1[i+1]-48;
        c = a*10+b;
        if(c%4 == 0){
            sum+=i+1;
        }
    }

    cout << sum << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int len1,len2,Len1,Len2;
string s3="";
int lon;
int baki;
int rem;
int S;

void func(int a, int c)
{
    int vagfol;//,rem;
    baki = baki*10+a; /// 20
    lon=baki; /// 20

   // while(lon!=0){

        rem = lon%c; /// 3
        lon = lon/c; /// 1

   // }
    baki = rem; /// 2
   // cout << baki << " ";
/// 2098765413
}

void Div(string s1)
{
    int len = s1.size();

   for(int i=0; i<len; i++){
        s3[0]=s1[i];
        s3[1]='\0';
        func(stoi(s3),4);

   }

   if(baki == 0) S++;
   //else cout << "0\n";
   lon=0,baki=0,rem=0;

}

void MakeSubstr(string s1)
{
    int len = s1.size();
    int a,b;
    a = len;
    string s2;

    for(int i=0; i<len; i++){
        for(int j=1; j<=a; j++){
            //if(s1[j] == '\0') break;
           // cout << s1.substr(i,j);

            Div(s1.substr(i,j));
            //cout << "\n";
        }
        a--;

    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s1,s2,ss;
    int n;

    cin >> s1;// >> n;

    MakeSubstr(s1);

    cout << S << "\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s1;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int sum=0;

    cin >> s1;

    for(int i=0; s1[i]!=0; i++){

        if((s1[i]-48)%4 == 0){
            sum++;
        }

        if(s1[i+1] == 0) break;

        int a,b,c;
        a = s1[i]-48;
        b = s1[i+1]-48;
        c = a*10+b;
        if(c%4 == 0){
            sum+=i+1;
        }
    }

    cout << sum << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main()
{
   fast;
   ll sum=0;
   string s1;
   cin >> s1;
   string s2="";
   for(int i=0; s1[i]!=0; i++){
      s2+=s1[i];
      if(s1[i] == '0' || s1[i] == '4' || s1[i] == '8') sum++;
      if(s2.size() == 2){
         if(stoi(s2)%4 == 0){
            sum+=i;
         }
         s2="";
         s2+=s1[i];
      }
   }
   cout << sum << "\n";

   return 0;
}


#include<bits/stdc++.h>
using namespace std;

int len1,len2,Len1,Len2;
string s3="";
int lon;
int baki;
int rem;
int S;

void func(int a, int c)
{
    int vagfol;//,rem;
    baki = baki*10+a; /// 20
    lon=baki; /// 20

   // while(lon!=0){

        rem = lon%c; /// 3
        lon = lon/c; /// 1

   // }
    baki = rem; /// 2
   // cout << baki << " ";
/// 2098765413
}

void Div(string s1)
{
    int len = s1.size();

   for(int i=0; i<len; i++){
        s3[0]=s1[i];
        s3[1]='\0';
        func(stoi(s3),4);

   }

   if(baki == 0) S++;
   //else cout << "0\n";
   lon=0,baki=0,rem=0;

}

void MakeSubstr(string s1)
{
    int len = s1.size();
    int a,b;
    a = len;
    string s2;

    for(int i=0; i<len; i++){
        for(int j=1; j<=a; j++){

            s2 = s1.substr(i,j);
            if(s2[j-1] == '3' || s2[j-1] == '1' || s2[j-1] == '5' || s2[j-1] == '9' || s2[j-1] == '7') continue;
            Div(s2);
            //cout << "\n";
        }
        a--;

    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s1,s2,ss;
    int n;

    cin >> s1;// >> n;

    MakeSubstr(s1);

    cout << S << "\n";

    return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
using namespace std;
int main(){
    string str;
    cin>>str;
    ull ans=0;
    for(int i=str.length()-1;i>=0;i--){
        if((str[i]-48)%4==0)ans++;
        if(i>0){
            if(((str[i]-48)+(str[i-1]-48)*10)%4==0){
                //cout<<"sa "<<i<<" as"<<endl;
                ans+=i;
            }
        }
    }
    cout<<ans<<endl;
return 0;
}


#include <bits/stdc++.h>
#define bos 0
using namespace std;
int main(){
    string str;
    cin>>str;
    int ans=0;
    for(int i=str.length()-1;i>=0;i--){
        if((str[i]-48)%4==0)ans++;
        if(i>0){
            if(((str[i]-48)+(str[i-1]-48)*10)%4==0){
                //cout<<"sa "<<i<<" as"<<endl;
                ans+=i;
            }
        }
    }
    cout<<ans<<endl;
return 0;
}


#include <bits/stdc++.h>
#define bos 0
using namespace std;
int main(){
    string str;
    cin>>str;
    int ans=0;
    for(int i=str.length()-1;i>=0;i--){
        if((str[i]-48)%4==0)ans++;
        if(i>0){
            if(((str[i]-48)+(str[i-1]-48)*10)%4==0 && str[i-1]!='0'){
                //cout<<"sa "<<i<<" as"<<endl;
                ans+=i;
            }
        }
    }
    cout<<ans<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
=bool bl[107];
string s;
ll len,cnt,x;

int main(){
	cin>>s;
	for(ll i=0;i<105;i+=4){
		bl[i]=1;
	}
	len = s.length();
	for(ll i=0;i<len;i++){
		bool bl2=bl[int(s[i])-'0'];
		if(bl2){cnt++;}
		if(i<len-1)	{
			x = 10 * (int(s[i])-'0');
			x += int(s[i+1])-'0';
			if(bl[x]){
				cnt+=i+1;
			}
		}
		}
	cout<<cnt;
	return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool bl[107];
string s;
int len,cnt,x;

int main(){
	cin>>s;
	for(int i=0;i<105;i+=4){
		bl[i]=1;
	}
	len = s.length();
	for(int i=0;i<len;i++){
		bool bl2=bl[int(s[i])-'0'];
		if(bl2){cnt++;}
		if(i<len-1)	{
			x = 10 * (int(s[i])-'0');
			x += int(s[i+1])-'0';
			if(bl[x]){
				cnt+=i+1;
			}
		}
		}
	cout<<cnt;
	return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 * 3 + 5;
bool bl[107];
string s;
ll len,cnt,x;

int main(){
	cin>>s;
	for(ll i=0;i<105;i+=4){
		bl[i]=1;
	}
	len = s.length();
	for(ll i=0;i<len;i++){
		bool bl2=bl[int(s[i])-'0'];
		if(bl2){cnt++;}
		if(i<len-1)	{
			x = 10 * (int(s[i])-'0');
			x += int(s[i+1])-'0';
			if(bl[x]){
				cnt+=i+1;
			}
		}
		}
	cout<<cnt;
	return 0;

}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
#define loop(x,n) for(int x = 0; x < n; x++)
#define Startloop(x,y,n) for(int x = y; x <= n; x++)

//For Dreamoon and Wifi
/*int factorial(int n){
	int dp[n+1];
	dp [0] = 1;
	Startloop(i,1, n){
		dp[i] = dp[i-1] * (i);
	}
	return dp[n];
}

int ncr(int n, int r){
	int ans = (factorial(n)) / (factorial(r) * factorial(n-r));
	return ans;

}*/

//Mike and Strings OLd helper function

/*pair<string, int> shortest(string a, string b, int l, int m){

	int tot = 0;
	string ta = a;
	//cout<<b<<" ";
	//cout<<a<<" "<<b<<" ";
	string tb = b;
	bool isPossible = false;
	while(tot <= l){
		if(ta == b){
			isPossible = true;
			break;
		}
		else{
			//cout<<'k';
			ta.push_back(ta[0]);
			ta.erase(0,1);
			tot++;
			//cout<<ta<<" ";

		}
	}
	//cout<<ta<<" ";
	if(isPossible == false){
		return make_pair("1", -1);
	}
	//isPossible = false;
	int tot2 = 0;
	bool isGreater = false;
	//cout<<a<<'0'<<" ";
	while(tot2 <= l){
		if(b == a){
			//cout<<"in";
			//isPossible = true;
			break;
		} else if(tot2 >= tot){

			isGreater = true;
			break;
		}
		else{
			//cout<<'s'<<" ";
			b.push_back(b[0]);
			b.erase(0,1);
			tot2 += m;

		}
	}
	//cout<<b<<" ";

	//cout<<b<<" ";
	int fin;
	string mod;

	int fin = (isGreater) ? tot : tot2;
	string mod = (isGreater) ? tb : a;
	//cout<<b<<"or"<<a<<" ";
	//cout<<mod<<'2';
	pair<string, int> ret = make_pair(mod, fin);

	return ret;

}*/

int main(){
/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//Cut Ribbon
	/*int n, a, b, c;
	cin>>n>>a>>b>>c;

	int dp[4001];
	memset(dp, 0, sizeof(dp));
	loop(x, n){
		if(dp[x] == 0 && x!=0){
			continue;
		} if(x+a <= n){
			dp[x+a] = max(dp[x] + 1, dp[x+a]);
		}
		if(x+b <= n){

			dp[x+b] = max(dp[x] + 1, dp[x+b]);
		}
		if(x+c <= n){
			dp[x+c] = max(dp[x] + 1, dp[x+c]);
		}

	}
	cout<<dp[n];
	*/

//B. Dreamoon and Wifi
/* note use of std::setprecision to modify the accuracy of printed doubles
	string a;
	string b;
	cin>>a>>b;
	int correctPs= 0;
	int correctMs = 0;
	int accPs = 0;
	int accMs = 0;

	loop(i, a.size()){
		if(a[i] == '+'){
			correctPs++;
		}
		else{
			correctMs++;
		}
		if(b[i] == '+'){
			accPs++;
		}
		else if(b[i] == '-'){
			accMs++;
		}
	}
	if(accMs > correctMs || accPs > correctPs){
		cout<<0;
		return 0;
	}
	else{
		int r = a.size() - accPs - accMs;
		int tot = 1<<r;

		int place = max(correctMs - accMs, correctPs - accPs);

	 double prob =  ncr(r, place) / (double) tot;

    cout << std::setprecision(9);
		cout<<prob;
	}
*/

	//B. WOW Factor
	//solution using the QAQ method: not as efficient
/*	string s;
	cin>>s;
	vector <int> modified;
	bool firstW = false;
	loop(i, s.size()){
		if(s[i] == 'v' && s[i+1] == 'v'){
			if(firstW == false){
				//cout<<'k';
				firstW = true;
			}
			modified.push_back('w');

		}
		else if(firstW == true){
			//cout<<'i';
			if(s[i] == 'o'){
				modified.push_back('o');
			}
		}
	}

	vector<long long> qLefts;
	long long qCount = 0;
	long long qTotal = 0;
	for(int i = 0 ; i<modified.size(); i++){
		if(modified.at(i) == 'w'){
			qCount += 1;
			qTotal += 1;

		} else if (modified.at(i) == 'o'){

			qLefts.push_back(qCount);
			//qCount = 0;
		}

	}
	long long totalWOW = 0;
	for(int j : qLefts){
		//cout<<j<<endl;
		totalWOW += j * (qTotal - j);
	}
	cout<<totalWOW;
*/

//B. WOW Factor
	//new dp approach O(n)

	  /*string S; cin >> S;
    ll a = 0, b = 0, c = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'o') {
            b += a;
        } else if (i > 0 && S[i-1] == 'v') {
            a++;
            c += b;
        }
    }
    cout << c;*/

    //B. Mike and Strings

	/*int n;
	cin>>n;
	if(n==1){
		cout<<0;
		return 0;
	}
	string lis[n];

	loop(i, n){
		cin>>lis[i];
	}
	int len = lis[0].size();

	loop(j, n){
		lis[j] = lis[j] + lis[j];
	}
	int dp[n][len];
	for(int x = 0; x < n; x++){
		for(int y = 0; y<len; y++){
			dp[x][y] = 1e9;
		}
	}

	loop(i, len){
		dp[0][i] = i;
	}

	for(int a = 1; a<n; a++){
		for(int b = 0; b< len; b++){
			for(int c = 0; c<len; c++){
				if(lis[a].substr(b, len) == lis[a-1].substr(c, len)){
					dp[a][b] = min(dp[a][b], dp[a-1][c] +b );
				}
			}
		}
	}
	int ans = 1e9;
	//cout<<ans<<endl;
	loop(i, len){
		//cout<<dp[n-1][i];
				ans = min(ans, dp[n-1][i]);
	}
	if(ans == 1e9){
		cout<<-1;
		return 0;
	}
	else{
		cout<<ans;
	}*/

	//int min = 0;
	/*Startloop(i, 1, n-1){
		pair<string , int> ans = shortest(lis[i], lis[i-1], len, i);
		if(ans.first =="1"){
			cout<<-1;
			return 0;
		} else{
			//cout<<ans.first<<" "<<ans.second<<endl;
			lis[i] = ans.first;
			//cout<<lis[i]<<endl;
			min += ans.second;
		}
	}*/

	//lis[0].erase(0, 1);

	//cout<<min;

//B. Bear and Compressing
/*
	int n, q;
	cin>>n>>q;

	map<char, vector<string>> grid;
	loop(i, q){
		string in;
		char ch;
		cin>>in;
		cin>>ch;
		grid[ch].push_back(in);
	}
stack<pair<char, int>> s;
s.push(make_pair('a',1));
int count = 0;
while(!s.empty()){
	pair<char, int> node = s.top();
	s.pop();
	if(node.second == n){
		count++;
	}
	else{
		for(string a : grid[node.first]){
			s.push(make_pair(a[0], node.second + 1));
		}
	}
}
cout<<count;*/

	//

char str[300000];
//memset(str, '-', sizeof(str));
scanf("%s", str);

long long tot = 0;
int i = 0;
while( true){
	if(i == 29999){
		if((str[i] - '0') % 4 == 0){
			tot++;

		}
		break;
	}
	if(str[i+1] == 0){
			if((str[i] - '0') % 4 == 0){
			tot++;

		}
		break;

	}

	int t = str[i] - '0';
	if(t%4 == 0){
		//cout<<'i';
		tot++;
	}
	int o = str[i+1] - '0';
	if((t*10 + o) % 4 == 0){
		tot = tot+i+1;
	}
	i++;
}
cout<<tot;

/*if(str[9] == 0){
	cout<<"fr";
}*/

//cout<<sizeof(str)/sizeof(str[0]);
//printf("%d",str[0]-'0');
//int c = '0';
//cout<<c;

return 0;

}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
#define loop(x,n) for(int x = 0; x < n; x++)
#define Startloop(x,y,n) for(int x = y; x <= n; x++)

//For Dreamoon and Wifi
/*int factorial(int n){
	int dp[n+1];
	dp [0] = 1;
	Startloop(i,1, n){
		dp[i] = dp[i-1] * (i);
	}
	return dp[n];
}

int ncr(int n, int r){
	int ans = (factorial(n)) / (factorial(r) * factorial(n-r));
	return ans;

}*/

//Mike and Strings OLd helper function

/*pair<string, int> shortest(string a, string b, int l, int m){

	int tot = 0;
	string ta = a;
	//cout<<b<<" ";
	//cout<<a<<" "<<b<<" ";
	string tb = b;
	bool isPossible = false;
	while(tot <= l){
		if(ta == b){
			isPossible = true;
			break;
		}
		else{
			//cout<<'k';
			ta.push_back(ta[0]);
			ta.erase(0,1);
			tot++;
			//cout<<ta<<" ";

		}
	}
	//cout<<ta<<" ";
	if(isPossible == false){
		return make_pair("1", -1);
	}
	//isPossible = false;
	int tot2 = 0;
	bool isGreater = false;
	//cout<<a<<'0'<<" ";
	while(tot2 <= l){
		if(b == a){
			//cout<<"in";
			//isPossible = true;
			break;
		} else if(tot2 >= tot){

			isGreater = true;
			break;
		}
		else{
			//cout<<'s'<<" ";
			b.push_back(b[0]);
			b.erase(0,1);
			tot2 += m;

		}
	}
	//cout<<b<<" ";

	//cout<<b<<" ";
	int fin;
	string mod;

	int fin = (isGreater) ? tot : tot2;
	string mod = (isGreater) ? tb : a;
	//cout<<b<<"or"<<a<<" ";
	//cout<<mod<<'2';
	pair<string, int> ret = make_pair(mod, fin);

	return ret;

}*/

int main(){
/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//Cut Ribbon
	/*int n, a, b, c;
	cin>>n>>a>>b>>c;

	int dp[4001];
	memset(dp, 0, sizeof(dp));
	loop(x, n){
		if(dp[x] == 0 && x!=0){
			continue;
		} if(x+a <= n){
			dp[x+a] = max(dp[x] + 1, dp[x+a]);
		}
		if(x+b <= n){

			dp[x+b] = max(dp[x] + 1, dp[x+b]);
		}
		if(x+c <= n){
			dp[x+c] = max(dp[x] + 1, dp[x+c]);
		}

	}
	cout<<dp[n];
	*/

//B. Dreamoon and Wifi
/* note use of std::setprecision to modify the accuracy of printed doubles
	string a;
	string b;
	cin>>a>>b;
	int correctPs= 0;
	int correctMs = 0;
	int accPs = 0;
	int accMs = 0;

	loop(i, a.size()){
		if(a[i] == '+'){
			correctPs++;
		}
		else{
			correctMs++;
		}
		if(b[i] == '+'){
			accPs++;
		}
		else if(b[i] == '-'){
			accMs++;
		}
	}
	if(accMs > correctMs || accPs > correctPs){
		cout<<0;
		return 0;
	}
	else{
		int r = a.size() - accPs - accMs;
		int tot = 1<<r;

		int place = max(correctMs - accMs, correctPs - accPs);

	 double prob =  ncr(r, place) / (double) tot;

    cout << std::setprecision(9);
		cout<<prob;
	}
*/

	//B. WOW Factor
	//solution using the QAQ method: not as efficient
/*	string s;
	cin>>s;
	vector <int> modified;
	bool firstW = false;
	loop(i, s.size()){
		if(s[i] == 'v' && s[i+1] == 'v'){
			if(firstW == false){
				//cout<<'k';
				firstW = true;
			}
			modified.push_back('w');

		}
		else if(firstW == true){
			//cout<<'i';
			if(s[i] == 'o'){
				modified.push_back('o');
			}
		}
	}

	vector<long long> qLefts;
	long long qCount = 0;
	long long qTotal = 0;
	for(int i = 0 ; i<modified.size(); i++){
		if(modified.at(i) == 'w'){
			qCount += 1;
			qTotal += 1;

		} else if (modified.at(i) == 'o'){

			qLefts.push_back(qCount);
			//qCount = 0;
		}

	}
	long long totalWOW = 0;
	for(int j : qLefts){
		//cout<<j<<endl;
		totalWOW += j * (qTotal - j);
	}
	cout<<totalWOW;
*/

//B. WOW Factor
	//new dp approach O(n)

	  /*string S; cin >> S;
    ll a = 0, b = 0, c = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'o') {
            b += a;
        } else if (i > 0 && S[i-1] == 'v') {
            a++;
            c += b;
        }
    }
    cout << c;*/

    //B. Mike and Strings

	/*int n;
	cin>>n;
	if(n==1){
		cout<<0;
		return 0;
	}
	string lis[n];

	loop(i, n){
		cin>>lis[i];
	}
	int len = lis[0].size();

	loop(j, n){
		lis[j] = lis[j] + lis[j];
	}
	int dp[n][len];
	for(int x = 0; x < n; x++){
		for(int y = 0; y<len; y++){
			dp[x][y] = 1e9;
		}
	}

	loop(i, len){
		dp[0][i] = i;
	}

	for(int a = 1; a<n; a++){
		for(int b = 0; b< len; b++){
			for(int c = 0; c<len; c++){
				if(lis[a].substr(b, len) == lis[a-1].substr(c, len)){
					dp[a][b] = min(dp[a][b], dp[a-1][c] +b );
				}
			}
		}
	}
	int ans = 1e9;
	//cout<<ans<<endl;
	loop(i, len){
		//cout<<dp[n-1][i];
				ans = min(ans, dp[n-1][i]);
	}
	if(ans == 1e9){
		cout<<-1;
		return 0;
	}
	else{
		cout<<ans;
	}*/

	//int min = 0;
	/*Startloop(i, 1, n-1){
		pair<string , int> ans = shortest(lis[i], lis[i-1], len, i);
		if(ans.first =="1"){
			cout<<-1;
			return 0;
		} else{
			//cout<<ans.first<<" "<<ans.second<<endl;
			lis[i] = ans.first;
			//cout<<lis[i]<<endl;
			min += ans.second;
		}
	}*/

	//lis[0].erase(0, 1);

	//cout<<min;

//B. Bear and Compressing
/*
	int n, q;
	cin>>n>>q;

	map<char, vector<string>> grid;
	loop(i, q){
		string in;
		char ch;
		cin>>in;
		cin>>ch;
		grid[ch].push_back(in);
	}
stack<pair<char, int>> s;
s.push(make_pair('a',1));
int count = 0;
while(!s.empty()){
	pair<char, int> node = s.top();
	s.pop();
	if(node.second == n){
		count++;
	}
	else{
		for(string a : grid[node.first]){
			s.push(make_pair(a[0], node.second + 1));
		}
	}
}
cout<<count;*/

	//

char str[300000];
//memset(str, '-', sizeof(str));
scanf("%s", str);

long long tot = 0;
int i = 0;
while( true){
	if(i == 299999){
		if((str[i] - '0') % 4 == 0){
			tot++;

		}
		break;
	}
	if(str[i+1] == 0){
			if((str[i] - '0') % 4 == 0){
			tot++;

		}
		break;

	}

	int t = str[i] - '0';
	if(t%4 == 0){
		//cout<<'i';
		tot++;
	}
	int o = str[i+1] - '0';
	if((t*10 + o) % 4 == 0){
		tot = tot+i+1;
	}
	i++;
}
cout<<tot;

/*if(str[9] == 0){
	cout<<"fr";
}*/

//cout<<sizeof(str)/sizeof(str[0]);
//printf("%d",str[0]-'0');
//int c = '0';
//cout<<c;

return 0;

}


#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
#define loop(x,n) for(int x = 0; x < n; x++)
#define Startloop(x,y,n) for(int x = y; x <= n; x++)

//For Dreamoon and Wifi
/*int factorial(int n){
	int dp[n+1];
	dp [0] = 1;
	Startloop(i,1, n){
		dp[i] = dp[i-1] * (i);
	}
	return dp[n];
}

int ncr(int n, int r){
	int ans = (factorial(n)) / (factorial(r) * factorial(n-r));
	return ans;

}*/

//Mike and Strings OLd helper function

/*pair<string, int> shortest(string a, string b, int l, int m){

	int tot = 0;
	string ta = a;
	//cout<<b<<" ";
	//cout<<a<<" "<<b<<" ";
	string tb = b;
	bool isPossible = false;
	while(tot <= l){
		if(ta == b){
			isPossible = true;
			break;
		}
		else{
			//cout<<'k';
			ta.push_back(ta[0]);
			ta.erase(0,1);
			tot++;
			//cout<<ta<<" ";

		}
	}
	//cout<<ta<<" ";
	if(isPossible == false){
		return make_pair("1", -1);
	}
	//isPossible = false;
	int tot2 = 0;
	bool isGreater = false;
	//cout<<a<<'0'<<" ";
	while(tot2 <= l){
		if(b == a){
			//cout<<"in";
			//isPossible = true;
			break;
		} else if(tot2 >= tot){

			isGreater = true;
			break;
		}
		else{
			//cout<<'s'<<" ";
			b.push_back(b[0]);
			b.erase(0,1);
			tot2 += m;

		}
	}
	//cout<<b<<" ";

	//cout<<b<<" ";
	int fin;
	string mod;

	int fin = (isGreater) ? tot : tot2;
	string mod = (isGreater) ? tb : a;
	//cout<<b<<"or"<<a<<" ";
	//cout<<mod<<'2';
	pair<string, int> ret = make_pair(mod, fin);

	return ret;

}*/

int main(){
/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//Cut Ribbon
	/*int n, a, b, c;
	cin>>n>>a>>b>>c;

	int dp[4001];
	memset(dp, 0, sizeof(dp));
	loop(x, n){
		if(dp[x] == 0 && x!=0){
			continue;
		} if(x+a <= n){
			dp[x+a] = max(dp[x] + 1, dp[x+a]);
		}
		if(x+b <= n){

			dp[x+b] = max(dp[x] + 1, dp[x+b]);
		}
		if(x+c <= n){
			dp[x+c] = max(dp[x] + 1, dp[x+c]);
		}

	}
	cout<<dp[n];
	*/

//B. Dreamoon and Wifi
/* note use of std::setprecision to modify the accuracy of printed doubles
	string a;
	string b;
	cin>>a>>b;
	int correctPs= 0;
	int correctMs = 0;
	int accPs = 0;
	int accMs = 0;

	loop(i, a.size()){
		if(a[i] == '+'){
			correctPs++;
		}
		else{
			correctMs++;
		}
		if(b[i] == '+'){
			accPs++;
		}
		else if(b[i] == '-'){
			accMs++;
		}
	}
	if(accMs > correctMs || accPs > correctPs){
		cout<<0;
		return 0;
	}
	else{
		int r = a.size() - accPs - accMs;
		int tot = 1<<r;

		int place = max(correctMs - accMs, correctPs - accPs);

	 double prob =  ncr(r, place) / (double) tot;

    cout << std::setprecision(9);
		cout<<prob;
	}
*/

	//B. WOW Factor
	//solution using the QAQ method: not as efficient
/*	string s;
	cin>>s;
	vector <int> modified;
	bool firstW = false;
	loop(i, s.size()){
		if(s[i] == 'v' && s[i+1] == 'v'){
			if(firstW == false){
				//cout<<'k';
				firstW = true;
			}
			modified.push_back('w');

		}
		else if(firstW == true){
			//cout<<'i';
			if(s[i] == 'o'){
				modified.push_back('o');
			}
		}
	}

	vector<long long> qLefts;
	long long qCount = 0;
	long long qTotal = 0;
	for(int i = 0 ; i<modified.size(); i++){
		if(modified.at(i) == 'w'){
			qCount += 1;
			qTotal += 1;

		} else if (modified.at(i) == 'o'){

			qLefts.push_back(qCount);
			//qCount = 0;
		}

	}
	long long totalWOW = 0;
	for(int j : qLefts){
		//cout<<j<<endl;
		totalWOW += j * (qTotal - j);
	}
	cout<<totalWOW;
*/

//B. WOW Factor
	//new dp approach O(n)

	  /*string S; cin >> S;
    ll a = 0, b = 0, c = 0;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'o') {
            b += a;
        } else if (i > 0 && S[i-1] == 'v') {
            a++;
            c += b;
        }
    }
    cout << c;*/

    //B. Mike and Strings

	/*int n;
	cin>>n;
	if(n==1){
		cout<<0;
		return 0;
	}
	string lis[n];

	loop(i, n){
		cin>>lis[i];
	}
	int len = lis[0].size();

	loop(j, n){
		lis[j] = lis[j] + lis[j];
	}
	int dp[n][len];
	for(int x = 0; x < n; x++){
		for(int y = 0; y<len; y++){
			dp[x][y] = 1e9;
		}
	}

	loop(i, len){
		dp[0][i] = i;
	}

	for(int a = 1; a<n; a++){
		for(int b = 0; b< len; b++){
			for(int c = 0; c<len; c++){
				if(lis[a].substr(b, len) == lis[a-1].substr(c, len)){
					dp[a][b] = min(dp[a][b], dp[a-1][c] +b );
				}
			}
		}
	}
	int ans = 1e9;
	//cout<<ans<<endl;
	loop(i, len){
		//cout<<dp[n-1][i];
				ans = min(ans, dp[n-1][i]);
	}
	if(ans == 1e9){
		cout<<-1;
		return 0;
	}
	else{
		cout<<ans;
	}*/

	//int min = 0;
	/*Startloop(i, 1, n-1){
		pair<string , int> ans = shortest(lis[i], lis[i-1], len, i);
		if(ans.first =="1"){
			cout<<-1;
			return 0;
		} else{
			//cout<<ans.first<<" "<<ans.second<<endl;
			lis[i] = ans.first;
			//cout<<lis[i]<<endl;
			min += ans.second;
		}
	}*/

	//lis[0].erase(0, 1);

	//cout<<min;

//B. Bear and Compressing
/*
	int n, q;
	cin>>n>>q;

	map<char, vector<string>> grid;
	loop(i, q){
		string in;
		char ch;
		cin>>in;
		cin>>ch;
		grid[ch].push_back(in);
	}
stack<pair<char, int>> s;
s.push(make_pair('a',1));
int count = 0;
while(!s.empty()){
	pair<char, int> node = s.top();
	s.pop();
	if(node.second == n){
		count++;
	}
	else{
		for(string a : grid[node.first]){
			s.push(make_pair(a[0], node.second + 1));
		}
	}
}
cout<<count;*/

char str[300000];
//memset(str, '-', sizeof(str));
scanf("%s", str);

long long tot = 0;
int i = 0;
while( str[i] != 0){
	if(i == 29999){
		if((str[i] - '0') % 4 == 0){
			tot++;

		}
		break;
	}
	if(str[i+1] == 0){
			if((str[i] - '0') % 4 == 0){
			tot++;

		}
		break;

	}

	int t = str[i] - '0';
	if(t%4 == 0){
		//cout<<'i';
		tot++;
	}
	int o = str[i+1] - '0';
	if((t*10 + o) % 4 == 0){
		tot = tot+i+1;
	}
	i++;
}
cout<<tot;

/*if(str[9] == 0){
	cout<<"fr";
}*/

//cout<<sizeof(str)/sizeof(str[0]);
//printf("%d",str[0]-'0');
//int c = '0';
//cout<<c;

return 0;

}


						/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost				  ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;
///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
////////////////////////

template<typename T>T set_bit(T N,T pos){return N=N | (1<<pos);}
template<typename T>T reset_bit(T N,T pos){return N= N & ~(1<<pos);}
template<typename T> bool check_bit(T N,T pos){return (bool)(N & (1<<pos));}
template<typename T>void bin_print(T N){bitset<25>bit(N);cerr<<bit.to_string()<<"\n";}
template<typename T> void max_self(T &a, T b){
	a=max(a,b);
}
template <typename T > void min_self(T &a, T b){
	a=min(a,b);
}
template <typename T > void add_self(T &a, T b){
	a+=b;
}
////////////////////////

const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;

template<typename T> void ara_read(T &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
template<typename T> void ara_print(T &v){
	for(ll x : v)
		printf("%lld ",x);
	puts("");
}
////////////////////////
const int nax = 3e5 + 10;
char s[nax];
int main()
{
	scanf("%s",s);
	int sz = (int) strlen(s);
	printf("%d\n",sz);

	vector < int > dp(sz+1);
	for(int i=0; i< sz ; i++){
		if(i==0){
			int temp = ctoi(s[i]);
			if(temp % 4 == 0){
				dp[i+1]=1;
			}
		}
		else{
			int temp = ctoi(s[i-1])*10 + ctoi(s[i]);
			if(temp%4==0)
				dp[i+1] = 1;
			if(ctoi(s[i]) % 4==0)
				dp[i+1] += 2;
		}
	}
	//~ debug() << dbg(dp);

	ll answer = 0;

	for(int i=1; i<= sz ; i++){
		for(int j =i ; j<= sz ; j++){
			if(i==j){
				if(dp[i]>1)
					answer++;
			}
			else if(dp[j]==1 || dp[j]==3){

				answer ++;
			}
		}
	}

	printf("%lld\n",answer);
    return 0;
}


						/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost				  ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;
///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
////////////////////////

template<typename T>T set_bit(T N,T pos){return N=N | (1<<pos);}
template<typename T>T reset_bit(T N,T pos){return N= N & ~(1<<pos);}
template<typename T> bool check_bit(T N,T pos){return (bool)(N & (1<<pos));}
template<typename T>void bin_print(T N){bitset<25>bit(N);cerr<<bit.to_string()<<"\n";}
template<typename T> void max_self(T &a, T b){
	a=max(a,b);
}
template <typename T > void min_self(T &a, T b){
	a=min(a,b);
}
template <typename T > void add_self(T &a, T b){
	a+=b;
}
////////////////////////

const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;

template<typename T> void ara_read(T &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
template<typename T> void ara_print(T &v){
	for(ll x : v)
		printf("%lld ",x);
	puts("");
}
////////////////////////
const int nax = 3e5 + 10;
char s[nax];
int main()
{
	scanf("%s",s);
	int sz = (int) strlen(s);
	//~ printf("%d\n",sz);

	vector < int > dp(sz+1);
	for(int i=0; i< sz ; i++){
		if(i==0){
			int temp = ctoi(s[i]);
			if(temp % 4 == 0){
				dp[i+1]=1;
			}
		}
		else{
			int temp = ctoi(s[i-1])*10 + ctoi(s[i]);
			if(temp%4==0)
				dp[i+1] = 1;
			if(ctoi(s[i]) % 4==0)
				dp[i+1] += 2;
		}
	}
	//~ debug() << dbg(dp);

	ll answer = 0;

	for(int i=1; i<= sz ; i++){
		for(int j =i ; j<= sz ; j++){
			if(i==j){
				if(dp[i]>1)
					answer++;
			}
			else if(dp[j]==1 || dp[j]==3){

				answer ++;
			}
		}
	}

	printf("%lld\n",answer);
    return 0;
}


						/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost				  ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;
///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
////////////////////////

template<typename T>T set_bit(T N,T pos){return N=N | (1<<pos);}
template<typename T>T reset_bit(T N,T pos){return N= N & ~(1<<pos);}
template<typename T> bool check_bit(T N,T pos){return (bool)(N & (1<<pos));}
template<typename T>void bin_print(T N){bitset<25>bit(N);cerr<<bit.to_string()<<"\n";}
template<typename T> void max_self(T &a, T b){
	a=max(a,b);
}
template <typename T > void min_self(T &a, T b){
	a=min(a,b);
}
template <typename T > void add_self(T &a, T b){
	a+=b;
}
////////////////////////

const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;

template<typename T> void ara_read(T &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
template<typename T> void ara_print(T &v){
	for(ll x : v)
		printf("%lld ",x);
	puts("");
}
////////////////////////
const int nax = 3e5 + 10;
char s[nax];
int main()
{
	scanf("%s",s);
	int sz = (int) strlen(s);
	//~ printf("%d\n",sz);

	vector < int > dp(sz+1);
	for(int i=0; i< sz ; i++){
		if(i==0){
			int temp = ctoi(s[i]);
			if(temp % 4 == 0){
				dp[i+1]=2;
			}
		}
		else{
			int temp = ctoi(s[i-1])*10 + ctoi(s[i]);
			if(temp%4==0)
				dp[i+1] = 1;
			temp = ctoi(s[i]);
			if(temp % 4==0)
				dp[i+1] += 2;
		}
	}
	debug() << dbg(dp);

	ll answer = 0;

	for(int i=1; i<= sz ; i++){
		for(int j =i ; j<= sz ; j++){
			if(i==j){
				if(dp[i]>1)
					answer++;
			}
			else if(dp[j]==1 || dp[j]==3){

				answer ++;
			}
		}
	}

	printf("%lld\n",answer);
    return 0;
}


						/*Saurav Paul*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost				  ios_base::sync_with_stdio(0);
#define eb                    emplace_back
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1e9+7
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
using namespace std;
///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
////////////////////////

template<typename T>T set_bit(T N,T pos){return N=N | (1<<pos);}
template<typename T>T reset_bit(T N,T pos){return N= N & ~(1<<pos);}
template<typename T> bool check_bit(T N,T pos){return (bool)(N & (1<<pos));}
template<typename T>void bin_print(T N){bitset<25>bit(N);cerr<<bit.to_string()<<"\n";}
template<typename T> void max_self(T &a, T b){
	a=max(a,b);
}
template <typename T > void min_self(T &a, T b){
	a=min(a,b);
}
template <typename T > void add_self(T &a, T b){
	a+=b;
}
////////////////////////

const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;

template<typename T> void ara_read(T &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
template<typename T> void ara_print(T &v){
	for(ll x : v)
		printf("%lld ",x);
	puts("");
}
////////////////////////
const int nax = 3e5 + 10;
char s[nax];
int main()
{
	scanf("%s",s);
	int sz = (int) strlen(s);
	//~ printf("%d\n",sz);

	vector < int > dp(sz+1);
	for(int i=0; i< sz ; i++){
		if(i==0){
			int temp = ctoi(s[i]);
			if(temp % 4 == 0){
				dp[i+1]=2 ;
			}
		}
		else{
			int temp = ctoi(s[i-1])*10 + ctoi(s[i]);
			if(temp%4==0)
				dp[i+1] = 1;
			temp = ctoi(s[i]);
			if(temp % 4==0)
				dp[i+1] += 2;
		}
	}
	//~ debug() << dbg(dp);

	ll answer = 0;

	for(int i=1 ; i <= sz ; i++){

		if(dp[i]==1 || dp[i]==3)
			answer += i-1;
		if(dp[i]==2 || dp[i]==3)
			answer += 1;
	}

	printf("%lld\n",answer);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    vector<ll> dp(3e5+1,0);
    cin>>s;
	int num=s[0]-'0';
	int num2;
	if(num%4==0)
		dp[0]=1;
	for(ll i=1;i<s.length();i++){
		num2=(s[i])-'0';
		if(num2%4==0)
			dp[i]=1;
		if((num*10+num2)%4==0)
			dp[i]+=i;
		num=num2;
	}
	ll sum_of_elems = 0;
	sum_of_elems = std::accumulate(dp.begin(),dp.end(), 0);
    cout<<sum_of_elems;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    vector<ll> dp(3e5+1,0);
    cin>>s;
	int num=s[0]-'0';
	int num2;
	if(num%4==0)
		dp[0]=1;
	for(ll i=1;i<s.length();i++){
		num2=s[i]-'0';
		if(num2%4==0)
			dp[i]=1;
		if((num*10+num2)%4==0)
			dp[i]+=i;
		num=num2;
	}
	ll sum_of_elems = 0;
	sum_of_elems = std::accumulate(dp.begin(),dp.end(), 0);
    cout<<sum_of_elems;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    vector<ll> dp(3e5+1,0);
    cin>>s;
	int num=s[0]-'0';
	int num2;
	if(num%4==0)
		dp[0]=1;
	for(ll i=1;i<s.length();i++){
		num2=s[i]-'0';
		if(num2%4==0)
			dp[i]=1;
		if((num*10+num2)%4==0)
			dp[i]+=i;
		num=num2;
	}
	ll sum_of_elems = 0;
	for(ll i=0;i<s.length();i++)
		sum_of_elems+=dp[i];
    cout<<sum_of_elems;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9

#define fs          first
#define sc          second
#define pb         push_back
#define mp(a,b)     make_pair(a,b)
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define pr1(x)      cout<<x<<"\n"
#define pr2(x,y)    cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)  cout<<x<<" "<<y<<" "<<z<<"\n"

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;

// clock
typedef long double f80;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//

const long long int mx=100000;
vector<vector<int>> adj;
unordered_map<int,bool> visited;

//modular exponentiation
LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m);
}
//
// dfs
void dfs(int x)
{
    visited[x]=true;
    for(int i=0;i<adj[x].size();i++)
    {
        if(!visited[adj[x][i]])
            dfs(adj[x][i]);
    }
}
//

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    string s;
    cin>>s;
    s='0'+s;
    LL ans=0;
    for(int i=1;i<s.size();i++)
    {
        int x=s[i]-'0';
        int y=s[i-1]-'0';
        if(x%4==0)
        {
            if(y&1)
                ans++;
            else
                ans+=i;
        }
        else if(x%2==0)
        {
            if(y&1)
                ans+=(i-1);
            else
                ans++;
        }

    }
    cout<<ans<<nl;

    #ifdef rd
    cout<<endl<<endl<<"Time elapsed: "<<(f80)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9

#define fs          first
#define sc          second
#define pb         push_back
#define mp(a,b)     make_pair(a,b)
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define pr1(x)      cout<<x<<"\n"
#define pr2(x,y)    cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)  cout<<x<<" "<<y<<" "<<z<<"\n"

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;

// clock
typedef long double f80;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//

const long long int mx=100000;
vector<vector<int>> adj;
unordered_map<int,bool> visited;

//modular exponentiation
LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m);
}
//
// dfs
void dfs(int x)
{
    visited[x]=true;
    for(int i=0;i<adj[x].size();i++)
    {
        if(!visited[adj[x][i]])
            dfs(adj[x][i]);
    }
}
//

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    string s;
    cin>>s;
    s='0'+s;
    LL ans=0;
    for(int i=1;i<s.size();i++)
    {
        int x=s[i]-'0';
        int y=s[i-1]-'0';
        if(x%4==0)
        {
            if(y&1)
                ans++;
            else
                ans+=i;
        }
        else if(x%2==0)
        {
            if(y&1)
                ans+=(i-1);
        }

    }
    cout<<ans<<nl;

    #ifdef rd
    cout<<endl<<endl<<"Time elapsed: "<<(f80)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9

#define fs          first
#define sc          second
#define pb         push_back
#define mp(a,b)     make_pair(a,b)
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define pr1(x)      cout<<x<<"\n"
#define pr2(x,y)    cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)  cout<<x<<" "<<y<<" "<<z<<"\n"

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;

// clock
typedef long double f80;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//

const long long int mx=100000;
vector<vector<int>> adj;
unordered_map<int,bool> visited;

//modular exponentiation
LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m);
}
//
// dfs
void dfs(int x)
{
    visited[x]=true;
    for(int i=0;i<adj[x].size();i++)
    {
        if(!visited[adj[x][i]])
            dfs(adj[x][i]);
    }
}
//

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    string s;
    cin>>s;
    s='0'+s;
    LL ans=0;
    for(int i=1;i<s.size();i++)
    {
        int x=s[i]-'0';
        int y=s[i-1]-'0';
        if(x%4==0)
        {
            if(y&1)
                ans++;
            else
                ans+=i;
        }
        else if(x%2==0)
        {
            if(y&1)
                ans+=i;
            else
                ans++;
        }

    }
    cout<<ans<<nl;

    #ifdef rd
    cout<<endl<<endl<<"Time elapsed: "<<(f80)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define mod         1000000007
#define pi          acos(-1.0)
#define eps         1e-9

#define fs          first
#define sc          second
#define pb         push_back
#define mp(a,b)     make_pair(a,b)
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define itn int

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define pr1(x)      cout<<x<<"\n"
#define pr2(x,y)    cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)  cout<<x<<" "<<y<<" "<<z<<"\n"

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;

// clock
typedef long double f80;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//

const long long int mx=100000;
vector<vector<int>> adj;
unordered_map<int,bool> visited;

//modular exponentiation
LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m);
}
//
// dfs
void dfs(int x)
{
    visited[x]=true;
    for(int i=0;i<adj[x].size();i++)
    {
        if(!visited[adj[x][i]])
            dfs(adj[x][i]);
    }
}
//

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    string s;
    cin>>s;
    s='0'+s;
    LL ans=0;
    for(int i=1;i<s.size();i++)
    {
        int x=s[i]'0';
        int y=s[i-1]-'0';
        if(x%4==0)
        {
            if(y&1)
                ans++;
            else
                ans+=i;
        }
        else if(x%2==0)
        {
            if(y&1)
                ans+=i;
            else
                ans++;
        }

    }
    cout<<ans<<nl;

    #ifdef rd
    cout<<endl<<endl<<"Time elapsed: "<<(f80)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif

}


#include<bits/stdc++.h>
#define ll long long
#define vlli vector<long long int>
#define vi vector<int>
#define hitAi ios_base::sync_with_stdio(false)
using namespace std;
int main(){
	hitAi;
	string str;
	getline(cin,str);
	ll cnt=0;int a=0,b=0,c=0;
	for(ll i=0;str[i]!='\0';i++){
		a=str[i]-'0';
		if(str[i+1]!='\0')
		b=str[i+1]-'0';
		if(b==0) c=a;
		else c=a*10+b;
		if(c%4==0&&b!=0) cnt+=i+1;
		if(a%4==0) cnt++;
		//cout<<c<<" "<<a<<" "<<cnt<<" ";
		b=0;c=0;a=0;
	}
	cout<<cnt;
	return 0;
}