/* Two Roads Diverged in a Wood, and I Took the One Less Travelled by,and That Has Made all the Difference */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define yes1 cout << "YES\n"
#define yes2 cout << "Yes\n"
#define no1 cout << "NO\n"
#define no2 cout << "No\n"
#define mod1 1000000007
#define mod2 998244353
#define pi 3.141592653589793238462643383279502884197
#define __lcm(a, b) ((a / __gcd(a, b)) * b)
// ans<0 (ans+mod)%mod
//(a/b)%mod=a*(b^MOD-2)
// void std_in_out() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); }
void solve()
{
string s; cin >> s;
int ans = 0;
for(int i = 0; i < s.size(); i++) {
if( s[i] >= '1' && s[i] <= '9') ans += s[i] - '0';
}
cout << ans << endl;
}
int32_t main()
{
ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// std_in_out()
int tc,t=0;
tc=1;
cin >> tc;
while(tc--)
{
// auto st = clock();
// cout<<"Case "<<++t<<": ";
solve();
// cerr << 1.0 * (clock() - st) / CLOCKS_PER_SEC << endl;
}
return 0;
}