#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string ch;
  bool B = true;
  cin >> ch;
  string str1 = ch.substr(0, 2);
  string str2 = ch.substr(3, 2);
  int hh = std::stoi(str1);
  int mm = std::stoi(str2);
  int l = hh / 10 + (hh % 10) * 10;
  int res = 0, sum = 0;
  if (l == mm) {
    cout << 0;
    return 0;
  }
  if (hh == 23 && mm < 32) {
    cout << 32 - mm;
    return 0;
  }
  if (hh == 23 && mm > 32) {
    cout << 60 - mm;
    return 0;
  }
  int x = 0;
  if (hh == 5 && mm > 50) {
    res = 10 - hh;
    sum = (res - 1) * 60 + 60 - mm;
    B = false;
  }
  if (hh == 15 && mm > 51) {
    res = 20 - hh;
    sum = (res - 1) * 60 + 60 - mm;
    B = false;
  }
  if (l >= 60 && hh != 23) {
    if (hh < 10 && hh >= 6) {
      res = 10 - hh;
      sum = (res - 1) * 60 + 60 - mm;
      B = false;
    } else if (hh >= 16 && hh < 20) {
      res = 20 - hh;
      sum = (res - 1) * 60 + 60 - mm;
      B = false;
    }
  }
  int l2;
  if (B == false) {
    l = (hh + res) / 10 + ((hh + res) % 10) * 10;
    l2 = l;
    mm = 0;
  } else
    l2 = (hh + 1 + res) / 10 + ((hh + res + 1) % 10) * 10;
  int u = l - mm;
  if (u < 0) {
    cout << 60 - mm + l2;
  } else if (u > 0) {
    if (hh == 23)
      cout << 60 - mm;
    else
      cout << u + sum;
  } else
    cout << sum;
  cout.precision(30);
  return 0;
}
