class Solution {
public:
    int getDecimalValue(ListNode* head) {
      ListNode* temp=head;
        int sum=0;
        int count =0;
        while(temp!=NULL)
        {
          count++;
          temp=temp->next;
        }
         ListNode* temp2=head;
        while(temp2!=NULL)
        {
            if(temp2->val==1)
            {
              sum+=(pow(2,count-1));
            }
            temp2=temp2->next;
            count--;
        }   
          return sum;
    }
};